Here is a way to create a system environment variable through VBScript
"JREPATH" = "C:\ProgramFiles\Java"
strVarName = "JREPATH"
strVarValue = "C:\ProgramFiles\Java"
Set objVarClass = GetObject( "winmgmts://./root/cimv2:Win32_Environment" )
Set objVar = objVarClass.SpawnInstance_
objVar.Name = strVarName
objVar.VariableValue = strVarValue
objVar.UserName = "<SYSTEM>"
objVar.Put_
WScript.Echo "Created environment variable " & strVarName
Set objVar = Nothing
Set objVarClass = Nothing
Thank you for reading :)
No comments:
Post a Comment