Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/6.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正在同一会话中与执行.bat文件_Powershell_Batch File - Fatal编程技术网

PowerShell正在同一会话中与执行.bat文件

PowerShell正在同一会话中与执行.bat文件,powershell,batch-file,Powershell,Batch File,我正在使用PowerShell以静默模式安装软件。安装已成功完成,但当我尝试执行几个批处理文件时,出现了一些异常 找不到给定模式的文件。系统找不到指定的路径 我的PowerShell中的命令: $inst_path = \\My installed drive (c:\program files\mysoftware\) & $inst_path\start-service.bat install 但是,当我关闭PowerShell ISE并执行相同的命令时,它正在正常工作,所以有人能

我正在使用PowerShell以静默模式安装软件。安装已成功完成,但当我尝试执行几个批处理文件时,出现了一些异常

找不到给定模式的文件。系统找不到指定的路径

我的PowerShell中的命令:

$inst_path = \\My installed drive (c:\program files\mysoftware\)
& $inst_path\start-service.bat install

但是,当我关闭PowerShell ISE并执行相同的命令时,它正在正常工作,所以有人能帮我克服这个问题吗?

bat文件的路径中有一个双斜杠,
$inst_path
变量和您构建的路径

您正在尝试调用
c:\program files\mysoftware\\start service.bat
——这将失败

请尝试以下方法:

$inst_path = "c:\program files\mysoftware"
& "$inst_path\start-service.bat" install

请告诉我,
某些异常会是什么?我觉得问题在于PowerShell会话,当我关闭ISE并重新执行脚本时,错误不一致,我没有收到任何错误