Reputation: 41
I've built an Inno Setup installer and am having some issues with my final step.
Initially I wanted to run a batch file upon completion (from the [Run]
section). This batch file starts a yajsw
service, and uses java.exe
.
I ran into a problem where the batch file wouldn't recognize java.exe
, even if I added it to the path locally or pathed directly to it in system32
.
I thought this could have something to do with Java not being in sysWOW64
, and being on a 64-bit machine.
Anyway, some requirements changed and I ended up simply opening an instance of explorer.exe
in the appropriate folder (that has several batch files) and giving directions as to which one to use. I do this in CurStepChanged()
when curStep
is ssDone
, by using Exec()
(or ShellExec
).
It seems that even double-clicking these batch files from this explorer window has the same problem of not recognizing java.exe
, but if I manually open an explorer window it works just fine.
I'm not sure if it matters but the test machine I'm using it on is running Windows Server 2008. I've tried using PrivilegesRequired=admin
, and I've tried calling ShellExec()
as well as Exec()
, and I've tried EnableFsRedirection(False)
.
Any ideas would be helpful, thanks!
EDIT: Since I'm not calling the batch file directly any more, and just trying to open the containing folder:
[Setup]
AppId={{264F5847-C34C-4DB1-9EBF-F4D730D7E846}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName=C:\TestInstall
DisableDirPage=yes
DefaultGroupName=foo
DisableProgramGroupPage=yes
OutputDir=C:\Project\installer
OutputBaseFilename=setup
Compression=lzma
SolidCompression=yes
UninstallFilesDir={code:InstallPath}
SetupIconFile=foo.ico
UninstallIconFile=foo.ico
SetupLogging=yes
...snip...
[Code]
...snip...
procedure CurStepChanged(CurStep: TSetupStep);
var
ResultCode: Integer;
cmd : String;
begin
if CurStep = ssDone then
begin
cmd := 'explorer.exe';
ShellExec('', cmd, InstallPath('') + '\server', '', SW_SHOW, ewNoWait, ResultCode);
end;
end;
and the batch file in the Installpath\server\
directory just is (basically...there are a couple batch files that all use java):
java.exe {various params}
Basically, even if I just have java.exe
, whether I fully path to it or add to the path locally, it doesn't work in the Explorer window that Inno fires off, but it DOES work if you open another one manually.
Thanks!
Upvotes: 2
Views: 1047
Reputation: 13085
You're running explorer with the wrong permissions. Use ShellExecAsOriginalUser
instead, or (better) use a [Run]
entry with Flags: postinstall shellexec
and a suitable Description
.
(Also, if you want to try going back to running java, then you could try using the useapppaths
flag, or querying the registry to find the correct path to Java.)
Upvotes: 1