2016-11-15 93 views
-1

我正在使用PowerShell以静默模式安装软件。安装成功完成,但是当我尝试执行一些批处理文件时,我收到了一些例外。PowerShell在同一会话中执行.bat文件

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

我的我的PowerShell命令里面:

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

但是当我关闭了PowerShell ISE中并执行它的工作没有任何异常相同的命令,所以有人可以帮我解决这个?

+0

什么,请告诉,将在'一些exceptions'是什么? – vonPryz

+0

我感觉到的问题是PowerShell会话,当我关闭ISE并重新执行脚本时,错误并不一致,我没有收到任何错误 – Nithya

回答

2

您在bat文件的路径中有双斜杠,包括$inst_path变量和您构建的路径。

您正试图拨打c:\program files\mysoftware\\start-service.bat - 哪个会失败。

试试这个:

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