![](/img/trans.png)
[英]Need a (script)procedure to install an application as windows service using NSIS script
[英]Can't get run my application after installing using NSIS script?
我為Java項目成功構建了nsis腳本。 我已經將我的Java項目轉換為名為test.bat
bat(Windows計算機需要bat文件才能執行)文件。 我的安裝步驟成功完成。
安裝后,bat文件無法啟動服務。 我已經檢查了以下路徑
Start Menu -> Control Panel -> Administrative Tools -> Services.
我可以在此列表中看到服務,但看不到我的服務文件名。
我已經嘗試按照腳本行
!define MUI_FINISHPAGE_RUN "$INSTDIR\test.bat"
我也嘗試過這個
Function test
ExecShell "" "$INSTDIR\test.bat"
FunctionEnd
如何解決呢?
我使用http://wrapper.tanukisoftware.org的包裝器安裝了Java服務,該服務能夠將jars安裝為服務。 IIRC,您需要在應用程序中安裝wrapper.exe,wrapper.dll和wrapper.jar。 檢查網站以獲取更多信息。
然后,您有NSIS調用該包裝程序以在目標計算機上安裝服務:
Detailprint "Installing service"
nsExec::Exec "$\"$INSTDIR\wrapper.exe$\" -i $\"$INSTDIR\wrapper.conf$\""
卸載程序部分:
Detailprint "Stopping service"
nsExec::Exec "$\"$INSTDIR\wrapper.exe$\" -p $\"$INSTDIR\wrapper.conf$\""
Detailprint "Removing service"
nsExec::Exec "$\"$INSTDIR\wrapper.exe$\" -r $\"$INSTDIR\wrapper.conf$\""
如您所見,您還必須創建wrapper.conf來指定有關服務的詳細信息(例如,使用哪個主類)。 安裝服務后,您應該可以使用類似...的方式啟動它。
Exec '"net start your_service_name"'
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.