如何在Windows XP中安装具有延迟自动启动类型的服务 [英] How to install a service with the delayed-auto startup type in Windows XP
问题描述
我的安装程序在Inno Setup中使用以下命令创建服务:
My installer creates services with the following command in Inno Setup:
Filename: {sys}\sc.exe; Check: IsAdminLoggedOn; Parameters: "create Example start= delayed-auto binPath= ""{app}\Example.exe"""; Flags: runhidden
此行在Windows XP之外的所有Windows中均有效,因为Windows XP不支持delayed-auto
启动类型.
由于两个原因,我需要使用delayed-auto
启动类型.
This line works in all Windows besides Windows XP because the delayed-auto
startup type is not supported in Windows XP.
I need to use the delayed-auto
startup type for two reasons.
- 我的服务需要始终在后台运行,而无需用户干预,这意味着该服务必须在启动时自动启动.
- 我的服务依赖于其他基本Windows服务,并且没有它们就无法运行,因此,我仅在所有基本服务启动后才使用
delayed-auto
来启动.
- My service needs to always run on the background without user intervention, which means that the service must automatically start on boot.
- My service depends on other basic windows services and cannot run without them, therefor I use the
delayed-auto
to start only after all the basic services are up.
那么我可以在Windows XP上创建具有类似于delayed-auto
的启动类型的服务吗?如果不是,那么有什么替代方法?
So can I create a service on Windows XP that has a startup type similar to that of delayed-auto
and if not then what are the alternatives?
推荐答案
delayed-auto
启动类型不适用于解决服务之间的依赖关系.如果您依赖的服务也具有delayed-auto
启动类型怎么办? delayed-auto
启动类型旨在通过延迟不必要的服务来加快计算机启动速度.
The delayed-auto
startup type is not intended to resolve dependency between services. What if the services you depend on also had delayed-auto
startup type? The delayed-auto
startup type is intended to speed up the computer start by delaying the non-essential services.
请参见 Windows服务的启动类型中的延迟启动"是做什么的?
要设置服务之间的依赖关系,请使用depend=
选项.
To set dependencies between services, use depend=
option.
sc.exe create Example start= delayed-auto binPath= "..." depend= service1/service2/service3
如果您仍想在Windows Vista和更高版本(建议使用)上使用delayed-auto
,只需创建两个[Run]
条目,一个用于Windows XP,一个用于Windows Vista(
If you still want to use delayed-auto
on Windows Vista and newer (what is recommended), just create two [Run]
entries, one for Windows XP and one for Windows Vista (Windows version 6.0) and newer.
; Delayed automatic start on Vista and newer
Filename: {sys}\sc.exe; Check: IsAdminLoggedOn; \
Parameters: "create Example start= delayed-auto binPath= ""{app}\Example.exe"" depend= service1/service2/service3"; \
Flags: runhidden; MinVersion: 6.0
; Automatic start on XP
Filename: {sys}\sc.exe; Check: IsAdminLoggedOn; \
Parameters: "create Example start= auto binPath= ""{app}\Example.exe"" depend= service1/service2/service3"; \
Flags: runhidden; OnlyBelowVersion: 6.0
另请参见在基于Windows版本的"Inno Setup Run"部分中执行不同的命令.
一种更好的解决方案,尽管稍微复杂一点,但它使用的是脚本常量一个>.它减少了代码重复.
A better, though a little more complicated solution, is using a scripted constant. It reduces code duplication.
这篇关于如何在Windows XP中安装具有延迟自动启动类型的服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!