简体   繁体   English

调试从 Inno Setup 安装程序执行的非工作批处理文件或命令

[英]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.

相关问题 从Inno Setup安装程序运行批处理文件失败 - Running batch file from Inno Setup installer is failing 如何在 Inno Setup 中运行批处理文件,同时在每个命令执行时显示进度 - How to run batch file in Inno Setup, while showing progress as each command gets executed 如何使用Inno Setup安装程序为运行的批处理文件提供输入? - How to provide an input to a batch file ran using Inno Setup installer? 命令行参数缺少特殊字符,如 ! 从 Inno Setup 通过批处理文件运行时 - Command line parameters missing special characters like ! when ran via batch file from Inno Setup Inno Setup:在安装过程完成后执行命令/批处理文件 - Inno Setup : execute command/batch file after install process is complete 使用ShellExecuteEx从Inno Setup中的批处理文件获取退出代码 - Get exit code from batch file in Inno Setup using ShellExecuteEx 从管理员设置中以管理员身份运行批处理文件(隐藏) - Run batch file as admin, hidden, from inno setup Inno Setup Batch 并行编译多个安装程序 - Inno Setup Batch compile more than one installer in parallel 从批处理文件执行时 MSI 安装程序不安装 - MSI installer does not install when executed from a batch file 带有 Exec 批处理和文件 Stream 进度的 Inno Setup 安装程序页面永远不会退出 Stream 并且即使正确终止 bat 也会无限期挂起 - Inno Setup installer page with Exec batch and file Stream progress never exits Stream and hangs indefinitely even with proper bat termination
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM