Вопрос

I am using START-PROCESS to call MSTEST with multiple arguments that define the container and test settings, however I think it's choking on the way I'm concatenating this. Should I use some other method of constructing this string before putting it into START-PROCESS?

Dim rwSettings As String = "\\PerfvsCtlr2\LoadtestSettings\PerfVSCtlr2forRemote.testsettings"
Dim rwContainer As String = "\\PerfvsCtlr2\LoadTest\LoadTestDefs\Heifer_Interactive_Peak_Workload.loadtest"
Dim rwResults As String = Workload.txtRwResults.Text
System.Diagnostics.Process.Start(Environment.GetEnvironmentVariable("VS110COMNTOOLS") & "..\Ide\MSTEST.EXE", "/Testsettings:""" & rwSettings & "" & " /Testcontainer:""" & rwContainer & "" & " /Resultsfile:""" & rwResults & "")

The problem is unknown currently, because process.start opens and closes the window far too quickly for me to catch any sort of error message. So my question is two-fold:

Does the above concatenation look correct? Is there a way I can get more information on either the final execution string Process.Start is putting together or the error message it's returning?

Это было полезно?

Решение

You can use Path.Combine to build paths and String.Format to build the arguments for Process.Start:

Dim rwSettings As String = "\\PerfvsCtlr2\LoadtestSettings\PerfVSCtlr2forRemote.testsettings"
Dim rwContainer As String = "\\PerfvsCtlr2\LoadTest\LoadTestDefs\Heifer_Interactive_Peak_Workload.loadtest"
Dim rwResults As String = "Workload.txtRwResults.Text"

Dim fileName = System.IO.Path.Combine(Environment.GetEnvironmentVariable("VS110COMNTOOLS"), "Ide\MSTEST.EXE")
Dim args = String.Format("/Testsettings:{0} /Testcontainer:{1} /Resultsfile:{2}", rwSettings, rwContainer, rwResults)

System.Diagnostics.Process.Start(fileName, args)

However, i must admit thar i'm not sure if this yields the desired result. It might give you an idea anyway.

Другие советы

I suspect that your problem is that you are not closing your quotation marks, for instance:

" /Testcontainer:""" & rwContainer & ""

Should be:

" /Testcontainer:""" & rwContainer & """"

Notice that the double-quotation mark at the end needs to be a quadruple quotation mark. Simply saying "" means an empty string.

Should you use something else? Probably. It would be more readable and efficient if you used StringBuilder or String.Format, but even so, you'll still have to fix the closing quotes issue.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top