电脑使用大量的环境变量,换电脑没有这几十个环境变量有些烦人,所以写了个工具批量写入环境变量和删除环境变量.
只需要简单的填写环境变量的配置ini就可以披露导入和删除,代替人工操作,完成后显示清单
示例
源码
由于需要引用easyini库的内容单独提供网盘下载
链接:https://pan.baidu.com/s/1JcNnJHL9z0M1_jPVuYrz8Q?pwd=cv0c
提取码:cv0c
–来自百度网盘超级会员V4的分享
#Include <ini>
if (!pa:=ini("path.ini"))
MsgBox,ini not exist
global out:=""
gui,add,text,,Write the env path you want to the INI file
gui,add,Button,gadd,add env path
gui,add,Button,gdel x+10,del env path
gui,show,,A tool for batch adding env path
return
GuiEscape:
GuiClose:
ExitApp
add:
for k,v in pa["path"]{
envpath(k,v)
}
MsgBox,% out
out:=""
return
del:
for k,v in pa["path"]{
envpath(k,v,"del")
}
MsgBox,% out
out:=""
return
envpath(name,path,mode:="add"){ ;if mode=add add envpath else del
if A_Is64bitOS
SetRegView 64
RegRead, OutputVar, HKEY_LOCAL_MACHINE, SYSTEM\CurrentControlSet\Control\Session Manager\Environment,%name%
if (mode="add"){
if (!OutputVar){
RegWrite, REG_SZ, HKEY_LOCAL_MACHINE, SYSTEM\CurrentControlSet\Control\Session Manager\Environment,%name%, %path%
out.="`n add " name " " path "success"
}else{
out.="`n " name " do not need to add"
}
}else{
if (OutputVar){
RegDelete, HKEY_LOCAL_MACHINE, SYSTEM\CurrentControlSet\Control\Session Manager\Environment,%name%
out.="`n delete " name " " path "success"
}else{
out.="`n " path "do not need to delete"
}
}
return out
}
境界又上升了一个度?