Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/11.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
Windows 如何从路径中有空白的PowerShell 5.0脚本调用批处理文件?_Windows_Powershell_Batch File - Fatal编程技术网

Windows 如何从路径中有空白的PowerShell 5.0脚本调用批处理文件?

Windows 如何从路径中有空白的PowerShell 5.0脚本调用批处理文件?,windows,powershell,batch-file,Windows,Powershell,Batch File,我正在尝试从PowerShell 5.0脚本调用批处理文件。批处理文件的路径为: \\192.168.0.1\hde_path\Tools Powershell\abc.cmd 因此,我的路径中有一个空白,我尝试用以下方式调用它 cmd.exe /c "'\\192.168.0.1\hde_path\Tools Powershell\abc.cmd'" 现在,它给出了错误: The system can not find the file specified. 但是,请注意: 此位置存在

我正在尝试从PowerShell 5.0脚本调用批处理文件。批处理文件的路径为:

\\192.168.0.1\hde_path\Tools Powershell\abc.cmd
因此,我的路径中有一个空白,我尝试用以下方式调用它

cmd.exe /c "'\\192.168.0.1\hde_path\Tools Powershell\abc.cmd'"
现在,它给出了错误:

The system can not find the file specified.
但是,请注意:

  • 此位置存在此文件abc.cmd
  • 我可以进入这个地方。 因为,我可以通过命令提示符运行这个abc.cmd文件,没有任何问题
同样,当我将abc.cmd文件放在某个路径中,该路径中没有任何空间时,例如:\192.168.0.1\hde\u path\Tools\abc.cmd,我使用以下命令调用它,它运行得非常好

cmd.exe /c '\\192.168.0.1\hde_path\Tools\abc.cmd'
请帮忙

cmd.exe /c '\\192.168.0.1\hde_path\Tools Powershell\abc.cmd'


应该有用。

双引号对我有用

cmd.exe /c "\\127.0.0.1\c$\temp\Test Folder\test.cmd"

只有双引号才能使用
cmd.exe/c“\\192.168.0.1\hde\u path\Tools\abc.cmd”
@JamesC。谢谢你的快速回复。但是,我想提醒您,您在评论中使用的路径中没有任何空间。但我需要调用一个有空格的批处理文件。@SrijaniGhosh,在上一个示例中,您的批处理文件也没有;无论如何,
cmd
使用
对于引号,
仅被视为普通字符…@aschipfl。。我知道我最后的例子不包含空格。因为,我在写一个例子,没有空格,代码运行良好。而对于空格,则不是。请通读整个问题。谢谢你的建议!我的评论仍然是正确的答案,我只是从你的问题中复制了错误的路径。
cmd.exe /c "\\127.0.0.1\c$\temp\Test Folder\test.cmd"