如何使用Inno Setup安装Windows服务? [英] How to install a Windows service with Inno Setup?

查看:386
本文介绍了如何使用Inno Setup安装Windows服务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了一个批处理脚本,以在使用Inno Setup完成安装后执行.问题是我在创建服务时使用以下命令行:

I wrote a batch script to execute after my installation that is made with Inno Setup. The problem is that I have the following command line for my service creation:

sc create MySQL start= auto DisplayName= MySQL binPath= "C:\MyApp\MySQL 5.5\bin\mysqld" --defaults-file="C:\MyApp\MySQL 5.5\my.ini"

带重音的字母是此代码的问题,如果我在cmd中打开bat文件,则无法执行该命令,但是键入时,服务将正常创建.我该如何解决?

The letters with accents are the problem of this code, I can't execute it if I open the bat file in cmd, but when I type the service is created normally. How can I fix that?

推荐答案

Rather than calling SC directly, it's cleaner (and easier to deal with any errors or service dependencies) to use the API. Note that this example assumes that you're using ANSI Inno, but it's fairly straightforward to modify this for Unicode.

但是,就个人而言,我更喜欢将安装/启动/停止/卸载命令构建到服务可执行文件本身中,从而使其能够自动注册.显然,这不可能为您自己提供第三方服务,但是您可以检查它是否已经支持这种服务.

Personally, though, I prefer to build install/start/stop/uninstall commands into the service executable itself, making it self-registering. Obviously this isn't possible to do yourself for a third-party service, but you could check to see if it already supports something like this.

最后一点是,您不得硬编码C:文件夹的路径.您应该改用{app}.

One final point is that you must not hard-code the path to a C: folder. You should be using {app} instead.

这篇关于如何使用Inno Setup安装Windows服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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