Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I wanna write a bat file to set system variables on any windows system. My software which I made needs to set a path instead of asking the user to process the method I heard we can do this task using bat files so I tried multiple ways to set a path nut most of them are duplicates of all existing paths instead of adding new ones and some times it's removing all paths and keeping only the new path

setx Path "%Path%;c:ffmpeg"

which is duplicating all the existing path variable

I did read multiple Stackoverflow queries on this but none helped if ur testing on your system to check please save/make a copy of all ur paths first
Thank you Eswar

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
217 views
Welcome To Ask or Share your Answers For Others

1 Answer

i wouldn't recommend you to mess with system variables but if you want to store path for your program here's a script that will do the thing but before doing so i would encourage you to make make a backup for files and all the paths stored in system variable %Path% and if something happen read this but anyway here is a script that worked for me:

@echo off
echo validating Path
ping localhost -n 2 >nul
set "store_path=Path to your program "
rem /M to set the variable in system wide environment
setx Path "%path%;%store_path%"
setx Path "%path%;%store_path%" /M

simply i am storing the new path with the old one.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...