@leaveye
2019-01-23T15:46:29.000000Z
字数 2151
阅读 983
NSIS 反馈 解决
PackSettings.nsh 中:
!define AppIcon "app.icon" ; 在 dist文件夹中
PackMain.nsi 中:
; 在 Name 和 Caption 的下面添加!ifdef AppIconIcon "${AppRoot}\${AppIcon}"!endif
在其它创建快捷方式的位置,指定使用它,如:
; 自动启动快捷方式。SetOutPath $INSTDIR\${TOMCAT_SubDir}CreateShortcut "$SMPROGRAMS\Startup\${Product}.lnk" "$INSTDIR\${TOMCAT_SubDir}\bin\startup.bat" "" "$INSTDIR\${AppIcon}" 0 SW_SHOWMINIMIZED
这种方式就无需在启动里加快捷方式了。是 Apache 官方推荐的方法。
首先在 tomcat\bin 下创建个 _helper.bat 脚本文件:
@echo offif ""%1""==""--install"" goto to_installif ""%1""==""--uninstall"" goto to_uninstallif ""%1""==""--usage"" goto to_usageif ""%1""=="""" goto to_usagegoto to_promptrem ============================================:to_promptecho "ERR: unknown option '%1'" >&2:to_usageecho "_helper --install"echo "_helper --uninstall"echo "_helper --usage"goto _endrem ============================================:to_installcall "setenv.bat"rem 注册系统服务call service.bat install "%SERVICE_NAME%"rem 设置服务自动启动sc config "%SERVICE_NAME%" start= autogoto _endrem ============================================:to_uninstallcall "setenv.bat"rem 删除服务echo wait...tomcat8.exe //DS//"%SERVICE_NAME%"goto _endrem ============================================:_end
然后安装服务这样写:
; 注册系统服务。随系统自启。SetOutPath $INSTDIR\${TOMCAT_SubDir}\binExecWait '"$INSTDIR\${TOMCAT_SubDir}\bin\_helper.bat" --install'
在删除服务里这样写:
; 删除系统服务。可能需要稍稍等它停止服务。StrCpy $OUTDIR $INSTDIR\${TOMCAT_SubDir}\binExecWait '"$INSTDIR\${TOMCAT_SubDir}\bin\_helper.bat" --uninstall'
更新:记得在生成 setenv.bat 的段落,参照 JRE_HOME 设置下环境变量 SERVICE_NAME 。为服务命名。
参考
额外安装一个只有一行的 invisible.vbs 文件:
args = """" & WScript.Arguments(0) & """"args = args & " " & """" & WScript.Arguments(1) & """"args = args & " " & """" & WScript.Arguments(2) & """"' 假如被调用的批处理最多有 X 个参数,上面的就要累计到 Arguments(X)CreateObject("Wscript.Shell").Run args, 0, False
假定你安装到了 $INSTDIR 。
然后在执行某个 bat 脚本的时候:
; 从ExecWait '"xxx.bat" ...'; 改成ExecWait '"$SYSDIR\wscript.exe" "$INSTDIR\invisible.vbs" "xxx.bat" ...'
参考:
- Run a batch file in a completely hidden way: https://superuser.com/a/62646
