Sean Long
Sean Long

Reputation: 2301

Debugging a Powershell start-process line

I'm using Powershell's standard ISE to develop a script that, among other things, calls start-process using a pre-defined filepath. Here is the code:

$MSTEST ="C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\MSTEST.EXE"
$TESTSETTING="D:\Source\Test\DEV\FIREBIRD\QA\LoadTesting\WebTests\perfvsctlr2.testsettings"
$TESTCONTAINER1="D:\Source\Infinity\DEV\FIREBIRD\QA\LoadTesting\WebTests\Test.AppFx.LoadTesting.Test\LoadTestDefs\Test_Interactive_Peak_Workload.loadtest"
start-process $MSTEST -ArgumentList "/Testsetting: $TESTSETTING /Testcontainer: $TESTCONTAINER1 /resultsfile: $RESULTSFILE" 

When I pass the variables and then try to manually execute the start-process line from the Powershell prompt it simply opens a window and closes it without displaying the error. So far I've used the -NoNewWindow argument and tried calling Powershell from the Run line with the -noexit argument. So far, no luck.

Upvotes: 3

Views: 2659

Answers (1)

larsgregersen
larsgregersen

Reputation: 171

How is $RESULTSFILE defined?

You shouldn't have a space after the colon (and you generally have to look out for spaces in any of your arguments. You don't seem to have any, but spaces in arguments require proper quoting).

You can get the error message from Start-Process by calling it with some extra arguments (the line below produces an error on purpose):

Start-Process $MSTEST -ArgumentList "\testcontainer: file" -wait -NoNewWindow -RedirectStandardError err -RedirectStandardOutput out

Upvotes: 2

Related Questions