将参数发送到Visual Studio的开发人员命令提示符 [英] Sending arguments to Developer Command Prompt for Visual Studio

查看:102
本文介绍了将参数发送到Visual Studio的开发人员命令提示符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am not able to pass some parameters to my Dev cmd prompt for vs, I can do it with the classic cmd but not with this one. And I need it because I want to execute CodedUITests from an executable.

这是我的代码的样子:

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

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

It starts, but no args are inserted,what am I doing wrong ?

编辑1-这些都不起作用

EDIT 1 - None of these are working

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

OR

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

OR

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

OR

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

OR

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

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

EDIT 2 - This is how my final code looks like, partially working, dev cmd starting, but no way to parse args into it because any args I pass they go straight to cmd not to 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();

推荐答案

您尝试过这种方式吗?

Did you try this way?

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

-FMI 我认为它会以这种方式工作...但是不确定

I assume it will work this way... but not sure

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

Open sys default cmd prompt.. and give first param as batch file path (C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\Tools\VsDevCmd.bat) and give a space and add next attribute.

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

这篇关于将参数发送到Visual Studio的开发人员命令提示符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆