CMD-Script在一秒钟后停止执行

时间:2015-09-30 16:20:35

标签: batch-file inno-setup ngen

我正在尝试使用CMD脚本调用ngen来创建与InnoSetup一起安装的应用程序的本机映像。为此,当Curstep是ssPostInstall时,我通过在curStepChanged函数中调用ShellExec来运行所述脚本。脚本本身查找ngen的位置,并使用应用程序的路径作为参数调用它。 问题是脚本在aprox之后停止了。 1秒没有任何错误。 ShellExec返回true,脚本创建的日志文件为空。

这里的细节: InnoSetup:

procedure CurStepChanged(CurStep: TSetupStep);
var
Param : String;
ResultCode : Integer;
begin
    if CurStep=ssPostInstall then begin
        try
            ProgressPage.SetProgress(0,2);
            ProgressPage.SetText('Tell Application about the Database','');
            ProgressPage.Show;

            Exec(ExpandConstant('{tmp}') + '\XMLAndIniReplacer.exe',ExpandConstant('{app}')+'\Application.exe.config'+ ' ' +DBPage.Values[0] + ' ' + DBPage.Values[1] + ' ' + DBPage.Values[2] + ' ' + DBPage.Values[3] +  ' ' + ExpandConstant('{app}')+'\Application.ini' + ' ' + ExpandConstant('{language}'),'', SW_HIDE, ewWaitUntilTerminated, ResultCode)   

            ProgressPage.SetProgress(1,2);
            ProgressPage.SetText('Make Application faster ','This operation could take a few minutes');

            Param := '"' + ExpandConstant('{app}') + '"';

            if not ShellExec('', ExpandConstant('{tmp}') + '\ngen-run.cmd', Param,'', SW_SHOW, ewWaitUntilTerminated, ResultCode) then begin
                MsgBox(SysErrorMessage(ResultCode), mbError, MB_OK);
            end;
            ProgressPage.SetProgress(2,2);
        finally
            ProgressPage.Hide;
        end;
    end;       
end;

CMD-文件:

for /f "tokens=3* delims=    " %%a in ('reg.exe query   HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework /v InstallRoot') do set "UTILPATH=%%a\v4.0.30319\ngen.exe"
echo %1
echo %2
echo %UTILPATH%
%UTILPATH% %2 %1\Application.exe > ngen.log

一切正常,只是脚本被调用,打开大约一秒钟,然后关闭而不告诉我任何事情。此外,没有本机映像作为几兆字节的单个秒.exe会非常快。在CMD文件中投射的黑魔法也是其他人的作品。我不知道那里发生了什么。我只知道,它将应用程序作为参数调用ngen。到目前为止,它工作得很好。那么这里有什么不对吗?

1 个答案:

答案 0 :(得分:1)

为了清理问题,我通过让InnoSetup完成脚本所做的工作来解决这个问题。从注册表中提取ngen Path,以正确的路径作为参数运行ngen。通过这种方式,我可以控制ngen正在做什么,而且我还有一件事我不知道它是如何工作的。

相关问题