[关闭]
@leaveye 2019-01-23T15:46:29.000000Z 字数 2151 阅读 885

NSIS 问题反馈

NSIS 反馈 解决


图标 AppIcon 不起作用

PackSettings.nsh 中:

  1. !define AppIcon "app.icon" ; dist文件夹中

PackMain.nsi 中:

  1. ; Name Caption 的下面添加
  2. !ifdef AppIcon
  3. Icon "${AppRoot}\${AppIcon}"
  4. !endif

在其它创建快捷方式的位置,指定使用它,如:

  1. ; 自动启动快捷方式。
  2. SetOutPath $INSTDIR\${TOMCAT_SubDir}
  3. CreateShortcut "$SMPROGRAMS\Startup\${Product}.lnk" "$INSTDIR\${TOMCAT_SubDir}\bin\startup.bat" "" "$INSTDIR\${AppIcon}" 0 SW_SHOWMINIMIZED

注册 Tomcat 服务并自启及卸载

这种方式就无需在启动里加快捷方式了。是 Apache 官方推荐的方法。

首先在 tomcat\bin 下创建个 _helper.bat 脚本文件:

  1. @echo off
  2. if ""%1""==""--install"" goto to_install
  3. if ""%1""==""--uninstall"" goto to_uninstall
  4. if ""%1""==""--usage"" goto to_usage
  5. if ""%1""=="""" goto to_usage
  6. goto to_prompt
  7. rem ============================================
  8. :to_prompt
  9. echo "ERR: unknown option '%1'" >&2
  10. :to_usage
  11. echo "_helper --install"
  12. echo "_helper --uninstall"
  13. echo "_helper --usage"
  14. goto _end
  15. rem ============================================
  16. :to_install
  17. call "setenv.bat"
  18. rem 注册系统服务
  19. call service.bat install "%SERVICE_NAME%"
  20. rem 设置服务自动启动
  21. sc config "%SERVICE_NAME%" start= auto
  22. goto _end
  23. rem ============================================
  24. :to_uninstall
  25. call "setenv.bat"
  26. rem 删除服务
  27. echo wait...
  28. tomcat8.exe //DS//"%SERVICE_NAME%"
  29. goto _end
  30. rem ============================================
  31. :_end

然后安装服务这样写:

  1. ; 注册系统服务。随系统自启。
  2. SetOutPath $INSTDIR\${TOMCAT_SubDir}\bin
  3. ExecWait '"$INSTDIR\${TOMCAT_SubDir}\bin\_helper.bat" --install'

在删除服务里这样写:

  1. ; 删除系统服务。可能需要稍稍等它停止服务。
  2. StrCpy $OUTDIR $INSTDIR\${TOMCAT_SubDir}\bin
  3. ExecWait '"$INSTDIR\${TOMCAT_SubDir}\bin\_helper.bat" --uninstall'

更新:记得在生成 setenv.bat 的段落,参照 JRE_HOME 设置下环境变量 SERVICE_NAME 。为服务命名。

参考

调用程序的窗口完全隐藏

额外安装一个只有一行的 invisible.vbs 文件:

  1. args = """" & WScript.Arguments(0) & """"
  2. args = args & " " & """" & WScript.Arguments(1) & """"
  3. args = args & " " & """" & WScript.Arguments(2) & """"
  4. ' 假如被调用的批处理最多有 X 个参数,上面的就要累计到 Arguments(X)
  5. CreateObject("Wscript.Shell").Run args, 0, False

假定你安装到了 $INSTDIR
然后在执行某个 bat 脚本的时候:

  1. ;
  2. ExecWait '"xxx.bat" ...'
  3. ; 改成
  4. ExecWait '"$SYSDIR\wscript.exe" "$INSTDIR\invisible.vbs" "xxx.bat" ...'

参考:

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注