Batch modify environment variables

Management system environment setting
1, acquires the environment variable temp
wmic ENVIRONMENT where "name = 'temp '" get UserName, VariableValue

2, change the path environment variable values, the new e: \ tools NOTE: The path can not be used to add a variable, you must use an absolute path value such as: e: \ tools
WMIC the WHERE ENVIRONMENT "name = 'path' and username = ''" the SET VariableValue = "% path%; e : \ tools"

3, the new Home system environment variables, is HOMEDRIVE %% HOMEPATH%%
WMIC ENVIRONMENT Create name = "Home", username = "", the VariableValue = "% HOMEDRIVE %% HOMEPATH%"

4, delete the home environment variable
wmic ENVIRONMENT where "name = 'home '" delete

5, a variable is determined that there is added is skipped (such as the presence of C: \ Users \ Administrator \ Desktop \ Release0314, execution jumps to run after the command)
@echo% path% | the findstr / I "C: \ the Users \ Administrator \ Desktop \ Release0314 "&& (GOTO RUN)
WMIC ENVIRONMENT WHERE" name = 'path' and username = '' "= the VariableValue SET"% path%; C: \ the Users \ Administrator \ Desktop \ Release0314 "
: RUN
@echo" Hello "

Published 18 original articles · won praise 0 · Views 5614

Guess you like

Origin blog.csdn.net/M_ZONE125/article/details/104882402