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

查看:125
本文介绍了调试无法运行的批处理文件或从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.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"

奇怪的是,当我手动将其粘贴到命令行时,它可以工作.起初我以为这是一个权限问题,但是net.exe命令有效并且Tomcat并没有对此产生疑问.另外,我具有设置为admin所需的特权,并且应用程序需要admin特权才能启动安装程序,因此我不认为这是用户问题.我是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:\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

推荐答案

执行批处理文件(或任何命令)时,其结果(或错误)根本不可见(尤其是使用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在运行批处理文件时会自行隐式地运行该命令),但这一次使用/K开关,而不是更常见的/C开关. /K开关可确保控制台窗口不会自行关闭.

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.

所以代替:

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

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

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