Inno Setup:powershell脚本调用总是返回2

时间:2014-08-08 08:38:19

标签: powershell cmd installation inno-setup

我想从Inno setup启动一个powershell脚本,它总是返回2(系统找不到指定的文件)。我试过很多方面,返回代码总是2。

try
    ExtractTemporaryFile( 'GetOlderVersionUninstallString.ps1' );    
  except
    ShowExceptionMessage();
  end;

  TempDir := ExpandConstant('{tmp}');
  //v1
  ShellExec('open' ,'cmd /c powershell.exe', ' -executionpolicy bypass ".\GetOlderVersionUninstallString.ps1"', TempDir , SW_SHOW, ewWaitUntilTerminated, ErrorCode);
  MsgBox('Return code: ' + IntToStr( ErrorCode ), mbConfirmation, MB_OK);
  //v2
  Exec('powershell.exe', '-noexit -noninteractive -executionpolicy bypass "' + TempDir + '\GetOlderVersionUninstallString.ps1"', '', SW_SHOW, ewWaitUntilTerminated, ErrorCode);
  MsgBox('Return code: ' + IntToStr( ErrorCode ), mbConfirmation, MB_OK);

0 个答案:

没有答案