调试从 Inno Setup 安装程序执行的非工作批处理文件或命令 [英] Debugging non-working batch file or command executed from Inno Setup installer

查看:35
本文介绍了调试从 Inno Setup 安装程序执行的非工作批处理文件或命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 Inno Setup 通过命令行在 Windows 10 上安装 Tomcat 作为服务,但我目前遇到了问题,这是我的语法.

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.69inservice.bat; Flags: runascurrentuser; parameters: "tomcat7 //IS//Tomcat7 --DisplayName='Apache_Tomcat_7' ^ --Install='C:Program FilesTomcatin	omcat7.exe' --Jvm=auto ^ --StartMode=jvm --StopMode=jvm ^ --StartClass=org.apache.catalina.startup.Bootstrap --StartParams=start ^ --StopClass=org.apache.catalina.startup.Bootstrap --StopParams=stop"

奇怪的是,当我手动将其粘贴到命令行时它可以工作.起初我认为这是一个权限问题,但事实上 net.exe 命令有效并且 Tomcat 并没有对此提出质疑.此外,我需要将权限设置为管理员,并且该应用程序需要管理员权限才能启动安装程序,因此我认为这不是用户问题.我是 Inno Setup 的新手,有点卡在这里.

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.

调试输出:

[09:18:54.770] Filename: C:programOutput..apache-tomcat-   7.0.69inservice.bat 
[09:18:54.771] Parameters: tomcat7 //IS//Tomcat7 --DisplayName='Apache_Tomcat_7' ^ --Install='C:Program FilesTomcatin	omcat7.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

推荐答案

当你执行一个批处理文件(或任何命令)时,它的结果(或错误)要么根本不可见(特别是当 runhidden 标志被使用)或消失得那么快以至于你无法阅读它们.

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.

在这种情况下,通过 cmd.exe 显式运行命令(Inno Setup 在运行批处理文件时自己隐式运行),但这次使用 /Kswitch 而不是更常见的 /C 开关./K 开关确保控制台窗口不会自行关闭.当然,删除 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. The /K switch ensures that a console window does not close on its own. And of course, remove the runhidden flag.

所以代替:

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

或等价物:

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

使用:

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

然后控制台窗口在 setup.bat 完成后停留,您可以看到最终的错误.

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

如果批处理文件以隐藏正在执行的命令的常见@echo off命令开头,暂时用rem注释掉这一行也有助于调试.

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.

在cmd命令行中引用参数,请参见:
正确引用 cmd.exe 的多个参数

For quoting of arguments in cmd command-line, see:
Correct quoting for cmd.exe for multiple arguments

这篇关于调试从 Inno Setup 安装程序执行的非工作批处理文件或命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆