Starting VS IDE with WSH script causes catastrophic process failur
- From: Chris <Chris F@xxxxxxxxxxxxxxx>
- Date: Wed, 3 Dec 2008 14:51:02 -0800
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
.
- Follow-Ups:
- RE: Starting VS IDE with WSH script causes catastrophic process failur
- From: "Hongye Sun [MSFT]"
- RE: Starting VS IDE with WSH script causes catastrophic process failur
- From: Chris
- RE: Starting VS IDE with WSH script causes catastrophic process failur
- Prev by Date: RE: ActiveDirectory and user page Access
- Next by Date: RE: Starting VS IDE with WSH script causes catastrophic process failur
- Previous by thread: VSTS 2008 Licensing - I'm totally confused
- Next by thread: RE: Starting VS IDE with WSH script causes catastrophic process failur
- Index(es):
Relevant Pages
|