Tuesday, 15 February 2011

How to execute cmd commands in Inno Setup -



How to execute cmd commands in Inno Setup -

for installing mysql silently, tried next command in cmd , works fine:

msiexec /i "mysql-essential-6.0.11-alpha-winx64.msi" /qn

but, how can run command before installing in inno setup ?

you can execute calling exec function curstepchanged event method, when step ssinstall. in next script shown, how include mysql installer setup , how extract , execute right before installation starts:

#define mysqlinstaller "mysql-essential-6.0.11-alpha-winx64.msi" [files] source: "{#mysqlinstaller}"; flags: dontcopy [code] procedure curstepchanged(curstep: tsetupstep); var params: string; resultcode: integer; begin if (curstep = ssinstall) begin extracttemporaryfile('{#mysqlinstaller}'); params := '/i ' + addquotes(expandconstant('{tmp}\{#mysqlinstaller}')) + ' /qn'; if not exec('msiexec', params, '', sw_show, ewwaituntilterminated, resultcode) msgbox('installation of mysql failed. exit code: ' + inttostr(resultcode), mbinformation, mb_ok); end; end;

utilize unused progress bar:

since takes time before installation of mysql finishes, , you've decided hide user interface of installer (what might quite unsafe anyway), can extend script utilize progress bar shown @ starting position during installation , unused time. next code switches (on @ to the lowest degree windows xp systems) innosetup's installation progress bar marquee style , shows description in status label. when mysql installation done, progress bar switched normal mode , actual innosetup installation starts:

#define mysqlinstaller "mysql-essential-6.0.11-alpha-winx64.msi" [files] source: "{#mysqlinstaller}"; flags: dontcopy [code] procedure curstepchanged(curstep: tsetupstep); var params: string; resultcode: integer; begin if (curstep = ssinstall) begin wizardform.progressgauge.style := npbstmarquee; wizardform.statuslabel.caption := 'installing mysql. may take few minutes...'; extracttemporaryfile('{#mysqlinstaller}'); params := '/i ' + addquotes(expandconstant('{tmp}\{#mysqlinstaller}')) + ' /qn'; if not exec('msiexec', params, '', sw_show, ewwaituntilterminated, resultcode) msgbox('installation of mysql failed. exit code: ' + inttostr(resultcode), mbinformation, mb_ok); wizardform.progressgauge.style := npbstnormal; wizardform.statuslabel.caption := ''; end; end;

command-line inno-setup

No comments:

Post a Comment