strComputer = "." Set obj = GetObject("winmgmts:\\.\root\cimv2") Set objEnv = obj.Get("Win32_Environment").SpawnInstance_ objEnv.Name = "MyEnv" objEnv.UserName = "machine\lightbox" objEnv.VariableValue = "abcdefgh" objEnv.Put_
strComputer = "." Set obj = GetObject("winmgmts:\\.\root\cimv2") Set objItems = obj.ExecQuery _ ("select * from Win32_Environment where SystemVariable = False and Name = 'MyEnv'") For Each objItem in objItems objItem.Delete_ Next