如何使用NSIS脚本将应用程序安装为Windows服务

Suj*_*ran 4 windows-services nsis

如何使用NSIS脚本将应用程序安装为Windows服务?

我在脚本中使用了此命令,Exec '"sc.exe"但安装后在Windows服务中找不到与之相关的任何服务,因此请帮助我。

Tar*_*syk 6

NSIS 网站上有多个插件

对我来说似乎没有必要复杂,所以我最终sc直接使用工具。命令非常简单:

!define appName "theApp.exe"
!define displayName "My Awesome Service"
!define serviceName "MyAwesomeService"

ExecWait 'sc create ${serviceName} error= "severe" displayname= "${displayName}" type= "own" start= "auto" binpath= "$INSTDIR\${appName}"'
Run Code Online (Sandbox Code Playgroud)

此处sc create提供完整的参数列表


Sek*_*eki 5

也许NSIS 简单服务插件可以为您提供帮助。语法很简单

SimpleSC::InstallService "MyService" "My Service Display Name" "16" "2" "C:\MyPath\MyService.exe" "" "" ""
Pop $0 ; returns an errorcode (<>0) otherwise success (0)
Run Code Online (Sandbox Code Playgroud)

在此示例中,将服务安装为ServiceType自己的进程+ StartType自动+ NoDependencies +登录为系统帐户。有关魔术数字的含义,请参阅随附的帮助。

Wiki显示了使用NSIS处理服务的其他5种方法

  • 注意:**SIMple Service 插件不适用于 Unicode NSIS** (2认同)