inno setup - InnoSetup + MySQL ODBC script = Error Message -


i have been trying create installer using inno setup vb.net application.

this application has prerequisite dependency on mysql odbc. so, thinking if check system if mysql odbc present, , install if not. well, frank, newbie programmer, , know no hell debian, script language innosetup.

i looking since time, through google , stuff, couldn't find other examples, , tried coding script myself.

here's script:

; script generated inno setup script wizard. ; see documentation details on creating inno setup script files!  [setup] ; note: value of appid uniquely identifies application. ; not use same appid value in installers other applications. ; (to generate new guid, click tools | generate guid inside ide.) appid={{id goes here} appname=dcs appversion=1.0 ;appvername=dcs 1.0 apppublisher=syed defaultdirname={pf}\dcs disabledirpage=yes defaultgroupname=dcs disableprogramgrouppage=yes outputbasefilename=setup setupiconfile=c:\logo.ico compression=lzma solidcompression=yes  [languages] name: "english"; messagesfile: "compiler:default.isl"  [tasks] name: "desktopicon"; description: "{cm:createdesktopicon}"; groupdescription: "{cm:additionalicons}"; flags: unchecked  [files] source: "c:\vs12\projects\dcs\bin\debug\dcs.exe"; destdir: "{app}"; flags: ignoreversion source: "c:\vs12\projects\dcs\bin\debug\dcs.vshost.exe.config"; destdir: "{app}"; flags: ignoreversion source: "c:\vs12\projects\dcs\bin\debug\dcs.vshost.exe.manifest"; destdir: "{app}"; flags: ignoreversion source: "c:\vs12\projects\dcs\bin\debug\dcs.application"; destdir: "{app}"; flags: ignoreversion source: "c:\vs12\projects\dcs\bin\debug\dcs.exe.config"; destdir: "{app}"; flags: ignoreversion source: "c:\vs12\projects\dcs\bin\debug\dcs.exe.manifest"; destdir: "{app}"; flags: ignoreversion source: "c:\vs12\projects\dcs\bin\debug\dcs.pdb"; destdir: "{app}"; flags: ignoreversion source: "c:\vs12\projects\dcs\bin\debug\dcs.vshost.application"; destdir: "{app}"; flags: ignoreversion source: "c:\vs12\projects\dcs\bin\debug\dcs.vshost.exe"; destdir: "{app}"; flags: ignoreversion source: "c:\vs12\projects\dcs\bin\debug\dcs.xml"; destdir: "{app}"; flags: ignoreversion source: "c:\vs12\projects\dcs\bin\debug\mysql-connector-odbc-5.1.12-win32.msi"; destdir: "{app}"; flags: ignoreversion ; note: don't use "flags: ignoreversion" on shared system files  [code] function ismysqlodbcinstalled(): boolean; begin     if not regkeyexists(hkey_local_machine, 'software\odbc\odbcinst.ini\mysql odbc 5.1 driver')     result := true     else     result := false; end;  [icons] name: "{group}\dcs"; filename: "{app}\dcs.exe" name: "{commondesktop}\dcs"; filename: "{app}\dcs.exe"; tasks: desktopicon  [run] filename: {src}\mysql-connector-odbc-5.1.12-win32.msi; check: ismysqlodbcinstalled() filename: "{app}\dcs.exe"; description: "{cm:launchprogram,dcs}"; flags: nowait postinstall skipifsilent 

now, compile goes fine, , generates setup.exe executable. when run, app dcs gets installed, mysql odbc doesn't , gives error,

unable execute file: 'output path'\mysql-connector-odbc-5.1.12-win32.msi create process failed; code2. system cannot find file specified.   ok 

i thought output folder needs mysql-connector-odbc msi installation folder. check, copied manually, recompiled , ran setup, same, change:

unable execute file: 'output path'\mysql-connector-odbc-5.1.12-win32.msi create process failed; code193. %1 not vaild win32 application.   ok 

and also, wanted installer check mysql odbc driver before installation proceeds, here, after main application install. can please me correct script?

thanks

the problem lies in [run] section. you're going execute mysql odbc installer {src} path. since copy mysql-connector-odbc-5.1.12-win32.msi installer file {app} folder, must run same. fix [run] section of script way:

[run] ; on following line, run executable {app} directory instead ; of {src}; {src} folder folder in setup files located ; since not *.exe file, must specify shellexec flag filename: {app}\mysql-connector-odbc-5.1.12-win32.msi; check: ismysqlodbcinstalled(); flags: shellexec filename: "{app}\dcs.exe"; description: "{cm:launchprogram,dcs}"; flags: nowait postinstall skipifsilent 

update:

to meet additional requirement, run odbc driver installer before main installation process, i've made following script example (there kept parts relevant odbc driver setup).

anyway, guess might less annoying if run odbc driver installer in silent mode default setting, won't offer wizard user if there (but that's wider topic question; there parameters control odbc driver installer, , can pass second parameter of exec function maybe telling show window flag sw_hide instead of sw_shownormal, keep hidden user). please note, code untested:

[setup] appname=dcs appversion=1.0 defaultdirname={pf}\dcs  [files] ; keep 1 flag, "dontcopy"; tell installer not copy ; file entry target machine, part of setup binary , ; available manual extracting using extracttemporaryfile(s) function source: "c:\vs12\projects\dcs\bin\debug\mysql-connector-odbc-5.1.12-win32.msi"; flags: dontcopy  [run] ; remove odbc driver installer entry [run] section since [run] section ; executed after installation succesfully finished , requirement ; run before installation process ; filename: {app}\mysql-connector-odbc-5.1.12-win32.msi; check: ismysqlodbcinstalled()  [code] function ismysqlodbc51installed: boolean; begin   // result inverted in original code; original function returned   // true if odbc driver not installed, false otherwise, , according   // function name should vice-versa   result := regkeyexists(hkey_local_machine, 'software\odbc\odbcinst.ini\mysql odbc 5.1 driver'); end;  procedure curstepchanged(curstep: tsetupstep); var   resultcode: integer; begin   // if right before main installation starts , odbc driver not yet   // installed, then...   if (curstep = ssinstall) , not ismysqlodbc51installed   begin     // extract odbc installaer inno setup's temporary folder     extracttemporaryfile('mysql-connector-odbc-5.1.12-win32.msi');     // , execute odbc driver installation (it necessary use shellexec     // since not *.exe file); if execution fails, then...     if not shellexec('', expandconstant('{tmp}\mysql-connector-odbc-5.1.12-win32.msi'), '', '',        sw_shownormal, ewwaituntilterminated, resultcode)     begin       // show error message exit code       msgbox('mysql odbc driver setup failed!' + #13#10 + 'exit code: ' + inttostr(resultcode) +         '; ' + syserrormessage(resultcode), mberror, mb_ok);       // here can optionally call abort abort upcoming installation process       // if uncomment following line, main installation not run if       // odbc driver installer execution failed       // abort;     end;   end; end; 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -