Starting VS IDE with WSH script causes catastrophic process failur

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Hope this is the right forum; if not please point me in the right direction.
NOTE: I am also posting this question in the
microsoft.public.scripting.vbscript group.

Goal: Configure an environment variable that may change depending on which
branch of the source tree I am working on, then start Visual Studio IDE. If
I attempt to use Computer > Properties > Advanced > Environment Variables, I
will be changing it many times a day, because I am working in multiple
branches of our source. Hence I am trying to write a WSH script to
accomplish this purpose.

Script:
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!"_
& "\\.\root\cimv2")
Set objStartup = objWMIService.Get("Win32_ProcessStartup")
Set objConfig = objStartup.SpawnInstance_
objConfig.EnvironmentVariables("UnitTestingValues") _
= "C:\Utils\MyDir\UnitTestingValues.xml"
objConfig.ShowWindow = SW_NORMAL
Set objProcess = objWMIService.Get("Win32_Process")
objProcess.Create "C:\Program Files\Microsoft Visual Studio
9.0\Common7\IDE\devenv.exe", "C:\Program Files\Microsoft Visual Studio
9.0\Common7\IDE\", objConfig, intProcessID

Result: The VS IDE starts. I open a solution that contains a VB unit
testing project. When I attempt to open Test View, the process crashes
catastrophically--i.e., it just disappears without leaving a trace.

When I open the same solution by just clicking the VS 2008 icon and then go
thru the same steps, I am able to open Test View and run tests without a
problem. (They just don't work because the environment variable is not set
the way it needs to be.)

Additional Info: I have also tried using the Win32_ProcessStartup object
directly, without spawning a new instance.

Set objConfig = objWMIService.Get("Win32_ProcessStartup")
objConfig.EnvironmentVariables("UnitTestingValues") =
"C:\Utils\Scripts\Cassi\UnitTestingValues.xml"
objConfig.ShowWindow = SW_NORMAL
Set objProcess = objWMIService.Get("Win32_Process")
objProcess.Create 'etcetera...

The result is the same, unfortunately.

Is there a better way for me to set environment variables when starting a
new process? If I use simple *.cmd files, the devenv.exe process that gets
started does not inherit the parent process' environment variables,
unfortunately.

TIA -
--
Chris
.



Relevant Pages

  • Starting VS IDE with WSH causes catastrophic process failure
    ... branch of the source tree I am working on, then start Visual Studio IDE. ... Set objConfig = objStartup.SpawnInstance_ ... When I attempt to open Test View, ... started does not inherit the parent process' environment variables, ...
    (microsoft.public.scripting.vbscript)
  • RE: Starting VS IDE with WSH causes catastrophic process failure
    ... The VS IDE behavior changes when I omit the line of script ... When I attempt to open Test View, ... started does not inherit the parent process' environment variables, ...
    (microsoft.public.scripting.vbscript)
  • RE: Starting VS IDE with WSH script causes catastrophic process failur
    ... The VS IDE behavior changes when I omit the line of script ... When I attempt to open Test View, ... started does not inherit the parent process' environment variables, ...
    (microsoft.public.vsnet.general)
  • Re: code 9009 executing pre build command line VS2008
    ... In $folder, there is an existing xsd.exe file. ... The cause of the error is that Visual Studio cannot find the xsd.exe file. ... After changing environment variables, we must restart Visual Studio to make ... Microsoft Online Community Support ...
    (microsoft.public.vsnet.general)
  • Solution-global settings?
    ... I have what I suspect is a common problem with managing multiple ... manually change all the settings of each of the projects (and for each ... to set a bunch of environment variables before being able to build. ... this within Visual Studio. ...
    (microsoft.public.vc.language)