无法执行文件:CreateProcess失败;代码87.参数不正确

时间:2015-04-21 13:16:11

标签: inno-setup setup-project

我做了一个设置,我的功能直接在[Run]部分运行。此设置运行数据库脚本。它运行正常但是当它完成时抛出“无法执行文件:CreateProcress失败;代码87.参数不正确”。

导致此错误的原因是什么以及如何解决?

我的创作代码:

[Files]
Source: "E:\SQLInstallTEST\Scripts\RCabSoft.sql"; DestDir: {app}; Flags: ignoreversion

[Run]
Filename: "{code:SqlScript}";

[Code]

function SqlScript(Value: string): string;
var
  ResultCode: Integer;
  OutputText: String;

begin

        if FileExists(ExpandConstant('{pf32}\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\SSMS.exe')) then
            begin        
              ExtractTemporaryFile('RCabSoft.sql');        

              // Execute SQL Update Scripts        
                Exec('SqlCmd.exe', ' -e -E -S .' + ExpandConstant(' -i "{app}\RCabSoft.sql"'), '', SW_SHOW, ewWaitUntilTerminated, ResultCode);         
                MsgBox('Successful', mbInformation, MB_OK);          
       end;
end; 

的SnapShot:

enter image description here

1 个答案:

答案 0 :(得分:1)

看起来你实际上并没有从SqlScript函数返回一个字符串,即你没有写入内置的Result变量。

此外,您应该使用[Run]Exec,但不能同时使用两者,因为它们都是为了运行可执行文件。

(摘自我的评论)[Run]部分中尝试此操作:

Filename: "SqlCmd.exe"; Parameters: "-e -E -S . -i {app}\RCabSoft.sql"; Check: FileExists(ExpandConstant('{pf32}\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\SSMS.exe'))

并完全删除SqlScript函数。