小编gyn*_*tik的帖子

从 PowerShell 运行 cmd /c,文件路径中包含空格

我正在尝试在 PowerShell 中运行以下命令

PS C:\Users\Administrator> cmd /c "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\Tools\vsdevcmd.bat && nuget restore && msbuild mywebapp.sln /p:DeployOnBuild=true /p:PublishedProfile=ServerFolderProfile"
Run Code Online (Sandbox Code Playgroud)

这会产生错误

'C:\Program' is not recognized as an internal or external command. 
Run Code Online (Sandbox Code Playgroud)

我的路径有空格,我正在运行几个由 && 分隔的命令,这把一切搞乱了。我尝试过在各处添加引号,但无法使其正常工作。

如果我只运行命令的第一部分

cmd /c "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\Tools\vsdevcmd.bat"
Run Code Online (Sandbox Code Playgroud)

效果很好。但我也无法让其他命令工作。

powershell cmd

5
推荐指数
1
解决办法
2万
查看次数

标签 统计

cmd ×1

powershell ×1