繁体   English   中英

将参数发送到Visual Studio的开发人员命令提示符

[英]Sending arguments to Developer Command Prompt for Visual Studio

我无法将一些参数传递给我的Dev cmd提示符以输入vs,我可以使用经典cmd来完成此操作,但不能使用此命令来完成。 我需要它,因为我想从可执行文件执行CodedUITests。

这是我的代码如下所示:

String Path = @"C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Microsoft Visual Studio 2012\Visual Studio Tools\Developer Command Prompt for VS2012.lnk";

ProcessStartInfo proc = new ProcessStartInfo();
proc.FileName = Path;
proc.UseShellExecute = true;
proc.Arguments =  @"/c MSTest/h";
Process.Start(proc);

它开始了,但是没有插入参数,我在做什么错?

编辑1-这些都不起作用

Process.Start(Path, @"/c "+"MSTest/h"); - err : invalid path - in dev cmd prompt

要么

Process.Start(Path, @"/c ""MSTest/h"); -  err: invalid path - in dev cmd prompt

要么

Process.Start(Path, @"/c MSTest/h"); - nothing

要么

Process.Start(Path, "/c MSTest/h"); -nothing

要么

Process.Start(Path,  "MSTest/h");  -nothing

编辑2-这就是我的最终代码的样子,部分工作,dev cmd开始,但是没有办法将args解析为它,因为我传递的任何args都会直接进入cmd而不是dev-cmd

// ProcessStartInfo procStartInfo = new System.Diagnostics.ProcessStartInfo("cmd", @"%comspec% /k ""C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\Tools\VsDevCmd.bat""");
            ProcessStartInfo procStartInfo = new System.Diagnostics.ProcessStartInfo("cmd", @"%comspec% /k ""C:\Users\butoiu.edward\Desktop\VsDevCmd1.bat");            
            procStartInfo.UseShellExecute = false;
           // procStartInfo.Arguments = "/k MSTest";
            Process proc = new Process();

            proc.StartInfo = procStartInfo;
            proc.Start();


            proc.WaitForExit();

您尝试过这种方式吗?

    void OpenWithArguments()
    {
        Process.Start("IExplore.exe", "www.northwindtraders.com");
        Process.Start("path to exe", "argument");
    }

FMI MSDN链接

更新:

我认为它将以这种方式工作...但不确定

打开sys默认的cmd提示符..并将第一个参数作为批处理文件路径( C:\\Program Files (x86)\\Microsoft Visual Studio 11.0\\Common7\\Tools\\VsDevCmd.bat )并给出一个空格并添加下一个属性。

Process.Start("Path to EXE", "arg1 arg2")

lnk”文件,它实际上是Visual Studio cmd提示符的链接。您可以尝试使用位于“ C:\\ Program Files(x86)\\ Microsoft Visual Studio 10.0 \\ VC \\ vcvarsall.bat”中的原始文件代替该位置。

String Path = @"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat";

ProcessStartInfo proc = new ProcessStartInfo();
proc.FileName = Path;
proc.UseShellExecute = true;
proc.Arguments =  @"/c MSTest/h";
Process.Start(proc);

我希望这能帮到您。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM