我想从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);