LaB*_*cca 12 windows-services shellexecute
我用Delphi为客户端服务器应用程序创建了一个Windows服务.
要安装它,我使用
c:\Test\MyService.exe /install (or /uninstall)
Run Code Online (Sandbox Code Playgroud)
这将安装该服务,并在Windows服务中列出"MyService"名称和空描述.
如何定义不同的名称并插入描述(在运行时可以看到services.msc)?
注意:我需要这个,因为在同一台机器上我需要安装更多次相同的服务(每个数据库1个).
目前我唯一的解决方法是重命名服务exe,但我更愿意找到正确的命令行方式(因为我这样做ShellExecute).
更新:不知怎的,我会寻找类似的东西(这当然只是出于解释原因! - InstallService.exe是我刚刚发明的名字):
InstallService.exe c:\Test\MyService.exe /install /name='MyService1'
/description='This is my service for database 1'
Run Code Online (Sandbox Code Playgroud)
而且更紧凑的版本会很好:
c:\Test\MyService.exe /install /name='MyService1'
/description='This is my service for database 1'
Run Code Online (Sandbox Code Playgroud)
Dav*_*nan 13
Windows已经附带了您需要的实用程序,即sc create.
>sc create /?
DESCRIPTION:
Creates a service entry in the registry and Service Database.
USAGE:
sc create [service name] [binPath= ] ...
OPTIONS:
NOTE: The option name includes the equal sign.
A space is required between the equal sign and the value.
type=
(default = own)
start=
(default = demand)
error=
(default = normal)
binPath=
group=
tag=
depend=
obj=
(default = LocalSystem)
DisplayName=
password=
这将创建服务并允许您指定名称和显示名称.
要修改您需要的描述sc description:
>sc description /?
DESCRIPTION:
Sets the description string for a service.
USAGE:
sc description [service name] [description]
另一个明显的选择是在您的服务中构建命令行解析.这很容易做到.只需为服务BeforeInstall和/或AfterInstall事件分配处理程序,然后在那里处理交换机.
| 归档时间: |
|
| 查看次数: |
28562 次 |
| 最近记录: |