'# Code to set a System/user environment variable and Variable Value:
strVarName = "varWorkingDir"
strVarValue = "D:\"
Function Create_System_Environment_Variable(strVarName ,strVarValue )
Dim wshshell
Set wshshell = CreateObject("WScript.Shell")
Dim WshSysUserEnv
Set WshSysUserEnv= wshshell.Environment("User")
WshSysUserEnv("varAutomation_WorkingDir")= strVarValue
Set WshSysUserEnv= Nothing
End Function
'# Code to remove/delete the environment variable:
Function Remove_System_Environment_Variable(strVarName)
Dim wshshell
Set wshshell = CreateObject("WScript.Shell")
Dim WshSysUserEnv
Set WshSysUserEnv= wshshell.Environment("User")
WshSysUserEnv.Remove(strVarName)
Set WshSysUserEnv= Nothing
End Function
No comments:
Post a Comment