Passing parameters to exe

后端 未结 2 1131
一个人的身影
一个人的身影 2021-01-14 15:19

I have a number of scenarios in which I need to pass parameters to command line exes.

I\'ve seen a number of these answered to some extent on this site, but so far I

2条回答
  •  醉酒成梦
    2021-01-14 16:18

    Just pass parameters like you would in your BAT file.

    cd "$($env:ProgramFiles(x86))\Microsoft Visual Studio 10.0\Common7\IDE"
    devenv /command "File.BatchNewTeamProject C:\stuff\Project51.xml"
    

    That will pass two arguments to devenv.

    Now, I have run into a few cases where an application requires that quotes be in the string you pass it. I had some trouble with this and thought that PowerShell was dropping the quotes. But it turns out that the real problem is that PowerShell does not escape the quotes. So you need to do this.

    devenv /command '\"File.BatchNewTeamProject C:\stuff\Project51.xml\"'
    

提交回复
热议问题