简体   繁体   English

如何从NSIS完成页面执行命令

[英]How to execute a command from a NSIS finish page

After having tried various methods, I never got the finish page with a checkbox in it. 在尝试了各种方法之后,我再也没有找到带有复选框的完成页面。 Q&A on stackoverflow suggested to use the !define MUI_PAGE_FINISH_RUN command just before the !insertmacro MUI_PAGE_FINISH command. 有关stackoverflow的问答,建议在!define MUI_PAGE_FINISH_RUN命令之前使用!insertmacro MUI_PAGE_FINISH命令。

So I took the example WelcomeFinish.nsi and added only 1 line !define MUI_PAGE_FINISH_RUN "Notepad.exe" just before the !insertmacro MUI_PAGE_FINISH command. 所以我把例子WelcomeFinish.nsi并添加只有1线!define MUI_PAGE_FINISH_RUN "Notepad.exe"只是之前!insertmacro MUI_PAGE_FINISH命令。 Still no checkbox on the finish page. 结束页面上仍然没有复选框。

What am i doing wrong? 我究竟做错了什么? I am using Win7 Professional on a 64-bit machine 我在64位计算机上使用Win7 Professional

The following NSIS documentation describes how to accomplish this: http://nsis.sourceforge.net/Run_an_application_shortcut_after_an_install 以下NSIS文档描述了如何实现此目的: http : //nsis.sourceforge.net/Run_an_application_shortcut_after_an_install

You need to add the following defines before MUI_PAGE_FINISH : 您需要在MUI_PAGE_FINISH之前添加以下定义:

!define MUI_FINISHPAGE_RUN
!define MUI_FINISHPAGE_RUN_TEXT "Launch notepad"
!define MUI_FINISHPAGE_RUN_FUNCTION "StartNotepad"
!insertmacro MUI_PAGE_FINISH

We are setting MUI_FINISHPAGE_RUN to be empty and instead defining a function in MUI_FINISHPAGE_RUN_FUNCTION to be run (we're calling our function StartNotepad ). 我们将MUI_FINISHPAGE_RUN设置为空,而在MUI_FINISHPAGE_RUN_FUNCTION定义一个要运行的函数(我们将函数称为StartNotepad )。 It will launch the process we are interested in (or shortcut/lnk) using ExecShell : 它将使用ExecShell启动我们感兴趣的过程(或快捷方式/ lnk):

Function StartNotepad
  ExecShell "" "notepad.exe"
FunctionEnd

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM