0
我想从inno安装程序运行一个shell脚本,但其失败。这里是我的代码:InnoSetup - 不识别shell脚本
procedure CurStepChanged(CurStep: TSetupStep);
var
ErrorCode: Integer;
cmdString: String;
begin
if (CurStep=ssInstall)
then
cmdString := 'net stop wuauserv';
Exec(ExpandConstant('{cmd}'), '/C ' + cmdString, '', SW_SHOW, ewWaitUntilTerminated, ErrorCode);
if (CurStep=ssPostInstall)
then
cmdString := 'net start wuauserv';
Exec(ExpandConstant('{cmd}'), '/C ' + cmdString, '', SW_SHOW, ewWaitUntilTerminated, ErrorCode);
if Exec(ExpandConstant('{cmd}'), '/c {tmp}/wsus.bat', '', SW_SHOW, ewWaitUntilTerminated, ErrorCode) then
if (CurStep=ssDone)
then
cmdString := 'wuauclt /resetauthorization /detectnow & pause';
Exec(ExpandConstant('{cmd}'), '/C ' + cmdString, '', SW_SHOW, ewWaitUntilIdle, ErrorCode);
end;
第2显示一切正常,最后的命令失败,出现错误:
'wuauclt' is not recognized as an internal or external command,
operable program or batch file.
Press any key to continue . .
有什么建议?我相信它没有设置正确的工作目录,我试过Exec(ExpandConstant('{win}'),Exec(ExpandConstant('{sys}')和Exec(ExpandConstant('{cmd}')无济于事。
如果我是你,我会使用Windows Update Agent API。 – TLama
这对于我期望实现的(或者有技能的)来说有点太复杂。上述命令将完全适合我的目标,而不会使其复杂化......如果我能弄清楚为什么它不能正确运行。作为我安装的一部分,它将bat文件复制到应用程序目录,如果我在安装程序外部运行它可以正常工作,但是通过[RUN]或使用上述语句运行它也会失败。 – copyandpaster
再试一次,.bat文件被安装到应用程序目录,然后通过inno安装文件执行..但仍然得到相同的错误,wuauclt无法识别,如果我直接从应用程序目录运行文件,它工作正常。 – copyandpaster