Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Starting VS IDE with WSH causes catastrophic process failure

Reply
 
Old 12-03-2008   #1 (permalink)
Chris


 
 

Starting VS IDE with WSH causes catastrophic process failure

Hope this is the right forum; if not please point me in the right direction.
NOTE: I am also posting this in microsoft.public.vsnet.general.

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 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

My System SpecsSystem Spec
Old 12-03-2008   #2 (permalink)
Chris


 
 

RE: Starting VS IDE with WSH causes catastrophic process failure

Additional info: The VS IDE behavior changes when I omit the line of script
that sets the environment variable
(objConfig.EnvironmentVariables("UnitTestingValues") =
"C:\MyDir\MyFile.xml"). Instead of crashing, the IDE *hangs* when I attempt
to open Test View window...

--
Chris

"Chris" wrote:
Quote:

> Hope this is the right forum; if not please point me in the right direction.
> NOTE: I am also posting this in microsoft.public.vsnet.general.
>
> 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 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
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
catastrophic failure 0x8000FFFF General Discussion
Catastrophic failure 0x8000FFFF Live Messenger
Catastrophic Failure? Vista installation & setup
Catastrophic Failure Vista General
Re: Catastrophic Failure: Catastrophic Failure Complete PC Backup Info Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46