Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在文件路径中使用空格从PowerShell运行cmd/c_Powershell_Cmd - Fatal编程技术网

在文件路径中使用空格从PowerShell运行cmd/c

在文件路径中使用空格从PowerShell运行cmd/c,powershell,cmd,Powershell,Cmd,我正在尝试在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

我正在尝试在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"
这会产生错误

'C:\Program' is not recognized as an internal or external command. 
我的路径有空格,我正在运行几个以&&分隔的命令,这会把一切都搞糟。我试着到处引用,但都没用

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

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

它很好用。但是我不能让其他命令也工作。

我应该更仔细地阅读
cmd.exe的文档

它说

如果指定了/C或/K,那么命令行的其余部分将作为新shell中的立即命令处理。如果用引号括起来,则接受由命令分隔符“&”或“&&”分隔的多个命令

所以我不得不把命令改成

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

我应该更仔细地阅读
cmd.exe
的文档

它说

如果指定了/C或/K,那么命令行的其余部分将作为新shell中的立即命令处理。如果用引号括起来,则接受由命令分隔符“&”或“&&”分隔的多个命令

所以我不得不把命令改成

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

“如果可以的话,你应该把你的答案标记为这个问题的答案,这样它就不会“没有答案”。@AdamParsons当我尝试时,我收到一条信息,说我必须等到明天。“那么我就这么做。你应该把你的答案标记为这个问题的答案,这样就不会让它“没有答案”——如果可以的话。@AdamParsons当我尝试时,我收到一条消息说我必须等到明天。”。那我就做吧。