-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathwindows_env_path.vbs
More file actions
30 lines (25 loc) · 877 Bytes
/
windows_env_path.vbs
File metadata and controls
30 lines (25 loc) · 877 Bytes
1
Set wshShell = WScript.CreateObject("WScript.Shell") Set wshEnv = WshShell.Environment("User") 'Get the the script's directorySet fso = CreateObject("Scripting.FileSystemObject")cwd = fso.GetParentFolderName(WScript.ScriptFullName) 'Stores it in the %SimcPath% variablewshEnv("SimcPath") = cwd'Update %Path% when necessaryenvPath = wshEnv("Path")If Len(envPath) = 0 Then wshEnv("Path") = "%SimcPath%" changed=1ElseIf InStr(envPath, "%SimcPath%") = 0 Then wshEnv("Path") = envPath & ";%SimcPath%" changed=1End If'Notify the user about the changesmsg = "%SimcPath% was set to: " & vbNewLine & cwd & vbNewLine & vbNewLineIf changed = 1 Then msg = msg & "%Path% was changed for this user to:"Else msg = msg & "%Path% was already up-to-date for this user:"End Ifmsg = msg & vbNewLine & wshEnv("Path")MsgBox msg, vbOkOnly & vbInformation, "Success"