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

问题描述 投票:3回答:2

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

我在脚本Exec '"sc.exe"中使用了这个命令但是在安装后我找不到与它相关的Windows服务中的任何服务,所以请帮助我谢谢。

windows-services nsis
2个回答
5
投票

也许NSIS Simple Service plugin可以帮助你。语法很简单

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

这里的示例将服务安装为ServiceType自己的进程+ StartType自动+ NoDependencies + Logon作为系统帐户。有关幻数的含义,请参阅随附的帮助。

维基显示5 other methods处理与NSIS的服务。


-1
投票

下面是首先停止服务,卸载以前版本,从注册表中删除然后安装新副本的脚本。

“移动界面”部分

SimpleSC :: StopService“MobileInterface”“1”“60”SimpleSC :: RemoveService“MobileInterface”DeleteRegKey / ifempty HKLM“MobileInterface”RMDIR / r“$ INSTDIR \ MobileInterface \”

SetOutPath“$ INSTDIR \ MobileInterface”#define要安装的内容并将其放在输出路径文件“D:\ NCS.Sentinel \ NCS.Sentinel.MobileWebSvc \ bin \ Release \”中

SimpleSC :: InstallService“MobileInterface”“MobileInterface”“16”“2”“$ INSTDIR \ MobileInterface \ NCS.Sentinel.MobileWebSvc.exe”“”“”“”Pop $ 0;返回错误代码(<> 0)否则成功(0)SimpleSC :: StartService“MobileInterface”“”“100”

WriteRegStr HKLM "D:\NCS.Sentinel\NCS.Sentinel.MobileWebSvc\bin\Release\NCS.Sentinel.MobileWebSvc.exe"

WriteUninstaller“$ INSTDIR \ Uninstall.exe”

;存储安装文件夹; WriteRegStr HKCU“软件\移动接口”“”$ INSTDIR

SectionEnd

© www.soinside.com 2019 - 2024. All rights reserved.