[英]Debugging non-working batch file or command executed from Inno Setup installer
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.我正在尝试使用 Inno Setup 通过命令行在 Windows 10 上安装 Tomcat 作为服务,但我目前遇到了问题,这是我的语法。
[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.起初我认为这是一个权限问题,但事实上
net.exe
命令可以工作并且 Tomcat 并没有对此提出质疑。 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.
我是 Inno Setup 的新手,有点卡在这里。
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
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.当您执行批处理文件(或任何命令)时,其结果(或错误)要么根本不可见(尤其是在使用
runhidden
标志时),要么消失得很快以至于您无法读取它们。
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.在这种情况下,通过
cmd.exe
显式运行命令(Inno Setup 在运行批处理文件时自己隐式运行),但这次使用/K
开关而不是更常见的/C
开关。 The /K
switch ensures that a console window does not close on its own. /K
开关确保控制台窗口不会自行关闭。
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.然后控制台窗口在
setup.bat
完成后停留,您可以看到最终的错误。
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.如果批处理文件以隐藏正在执行的命令的常见
@echo off
命令开头,则使用rem
临时注释掉这一行也将有助于调试。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.