I have a peculiar problem and have exhausted all threads I can find on the issue.
SEE UPDATE BELOW
I am trying to run a bat file in the code section of an INNO installer via the Exec() function. The bat takes in an argument containing double quotes and then launches a java program (passes the argument on). Via INNO Exec(), the bat fails to launch a java program. However, if I open cmd and run the command myself it launches successfully.
INNO code:
[Setup]
AppName=blah
AppVersion=1.0
AppPublisher=blah
AppPublisherURL=www.blah.com
DefaultDirName={pf}\blah
DefaultGroupName=blah
AllowNoIcons=no
OutputBaseFilename=blah
SolidCompression=yes
Compression=lzma
ArchitecturesInstallIn64BitMode=x64
ArchitecturesAllowed=x64
AlwaysRestart=no
PrivilegesRequired=admin
[Dirs]
Name: "{app}";
[Files]
Source: "..\dummy3.txt";DestDir: "{app}"; Flags: ignoreversion 64bit deleteafterinstall; BeforeInstall: InstallExt();
[Code]
{ Install SPSS Extensions from SPEs }
procedure InstallExt();
var
ResultCode: integer;
begin
if not Exec('"C:\Program Files\IBM\SPSS\Statistics\25\installextbundles.bat"', '–download no –source "C:\Program Files\blah"', '', SW_SHOW, ewWaitUntilTerminated, ResultCode) then
begin
MsgBox('Could not install OLSPS Extensions: ' + IntToStr(ResultCode) ,mbError, mb_Ok);
end;
end;
I imagine that INNO is somehow changing the parameters passed to the bat / cmd. Any Ideas?
~~~~~~~ UPDATE ~~~~~~
As suggested below in the comments (ref: Debugging non-working batch file or command executed from Inno Setup installer), I ran it so that cmd stays open and commented out the ECHO off of the bat file.
[Run]
Filename: C:\Windows\SysWOW64\cmd.exe; Parameters: '/K "C:\Program files\IBM\SPSS\Statistics\25\installextbundlesdebug.bat" –download no –source "C:\Program files\blah"'
I Also ran it manually with ECHO on via CMD to compare the two.
"C:\Program files\IBM\SPSS\Statistics\25\installextbundlesdebug.bat" –download no –source "C:\Program files\blah"
The result: With a minor tweak to the bat file, I got it echoing the same output whether via manual cmd or exec(), with the exception that via cmd it then successfully launched an external java program and failed to do so via INNO. Exact same echo'ed output.