I can tell you only an approximate way to write a script.
We check if AutoCAD is running:
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colProcesses = objWMIService.ExecQuery( _
"Select Name From Win32_Process " _
& "Where Name = 'acad.exe'")
If colProcesses.Count >= 1 Then
Set objShell = Wscript.CreateObject("Wscript.Shell")
objShell.Run "notepad.exe"
else
Msgbox "No AutoCAD"
End If
Set or delete values of environment variables:
http://www.robvanderwoude.com/vbstech_data_environment.php
To set a variable, specify new values for its Name, UserName and/or VariableValue properties.
The following code, from the book Windows Server Cookbook
by Robbie Allen, creates a new system environment variable called FOOBAR:
strVarName = "FOOBAR"
strVarValue = "Foobar Value"
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
And the following code removes the environment variable again by giving it an empty value:
strVarName = "FOOBAR"
Set objVarClass = GetObject( "winmgmts://./root/cimv2:Win32_Environment" )
Set objVar = objVarClass.SpawnInstance_
objVar.Name = strVarName
objVar.VariableValue = ""
objVar.UserName = "<SYSTEM>"
objVar.Put_
WScript.Echo "Removed environment variable " & strVarName
Set objVar = Nothing
Set objVarClass = Nothing
Replace the dot in the GetObject commands by a remote computer name to manage environment variables on that remote computer.
--
Please select the Accept as Solution button if my post solves your issue or answers your question.