1
votes

I am trying to install Tomcat as a service on Windows 10 via command line using Inno Setup but I am running into problems currently this is my syntax.

[Run] 
Filename: net.exe; Flags: runascurrentuser; parameters: "user elt_user TrackFox38# /add"

; installs tomcat makes it run as a service NOTE THAT IN INNO THIS IS A SINGLE LINE
Filename: {src}\..\apache-tomcat-7.0.69\bin\service.bat; Flags: runascurrentuser; parameters: "tomcat7 //IS//Tomcat7 --DisplayName='Apache_Tomcat_7' ^ --Install='C:\Program Files\Tomcat\bin\tomcat7.exe' --Jvm=auto ^ --StartMode=jvm --StopMode=jvm ^ --StartClass=org.apache.catalina.startup.Bootstrap --StartParams=start ^ --StopClass=org.apache.catalina.startup.Bootstrap --StopParams=stop"

The weird thing is that it works when I manually paste it into command line. At first I thought it was a permissions issue but the fact that the net.exe command works and Tomcat doesn't calls that into question. Also I have privileges required set to admin and the app needs admin privileges to start the installer so I don't think its a user issue. I'm new to Inno Setup and a bit stuck here.

Debug output:

[09:18:54.770] Filename: C:\program\Output\..\apache-tomcat-   7.0.69\bin\service.bat 
[09:18:54.771] Parameters: tomcat7 //IS//Tomcat7 --DisplayName='Apache_Tomcat_7' ^ --Install='C:\Program Files\Tomcat\bin\tomcat7.exe' --Jvm=auto ^ --StartMode=jvm --StopMode=jvm ^ --StartClass=org.apache.catalina.startup.Bootstrap --StartParams=start ^ --StopClass=org.apache.catalina.startup.Bootstrap --StopParams=stop 
[09:18:54.867] Process exit code: 0
1

1 Answers

4
votes

When you execute a batch file (or any command), its results (or errors) are either not visible at all (particularly when runhidden flag is used) or disappear that quickly that you cannot read them.

In that case, run the command explicitly via cmd.exe (Inno Setup does it implicitly on its own when running batch files), but this time with /K switch instead of a more common /C switch. The /K switch ensures that a console window does not close on its own.

So instead of:

[Run] 
Filename: {app}\setup.bat; Parameters: "arguments"

or an equivalent:

[Run] 
Filename: {cmd}; Parameters: "/C ""{app}\setup.bat"" arguments"

Use:

[Run] 
Filename: {cmd}; Parameters: "/K ""{app}\setup.bat"" arguments"

Then the console window stays after the setup.bat finishes and you can see eventual errors.

If the batch file starts with common @echo off command that hides the commands being executed, temporarily commenting out this line with rem will help debugging too.

enter image description here