最新消息:

ExecCmd为NSIS提供了运行命令行不显示黑框的功能

nsis 永恒心锁 3420浏览 0评论
/*
ExecCmd为NSIS提供了运行命令行不显示黑框的功能
这个插件已经停止更新,已被ExecDos插件所代替.
ASYNC:不等进程执行完毕,如果想等待执行完毕可以使用"wait".
TEST:执行命令行并且显示黑框.
TIMEOUT:等待执行时间,过了指定的时候便终止程序运行.
ExecWait::wait:待待程序执行完毕.
*/
!AddPluginDir "../Plugins"
!define APP_NAME ExecCmd
!define DOS_APP consApp.exe
Name "${APP_NAME} Test"
OutFile "${APP_NAME}.exe"
!include "MUI2.nsh"
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English"
; 'exec' command line
; ExecCmd::exec [/NOUNLOAD] [/ASYNC] [/TEST] [/TIMEOUT=TO_MS] CMD_LINE [STDIN_STRING]
Section "Dummy Section" SecDummy
 SetOutPath "$EXEDIR" ; for stdin.txt and stdout.txt file names without path
; sync call - not requires wait and nounload
; stdin from file and stdout to file, works on old OSs
ExecCmd::exec /TEST 'cmd.exe /k "dir" & pause...'
 ExecCmd::exec '"$EXEDIRconsApp.exe" <stdin.txt >stdout.txt' ""
; stdin from string. More secure for passwords, but not works on Win98. >stdout is optional
# ExecCmd::exec '"$EXEDIRconsApp.exe" >stdout.txt' "test_login$r$ntest_pwd$r$n"
; async launch, stdout to file
# ExecCmd::exec /NOUNLOAD /ASYNC /TIMEOUT=2000
# '"$EXEDIRconsApp.exe" >stdout.txt' "test_login$r$ntest_pwd$r$n"
# Pop $0 ; thread handle for 'wait'
; can put some other code here for parallel execution
; it's time to check process exit code, $0 is thread handle we Pop'ed above
# ExecCmd::wait $0
 Pop $0 ; return value - process exit code or error or STILL_ACTIVE (259).
; normal exit code is 5 for consApp.exe
 MessageBox MB_OK "Exit code $0"
SectionEnd
Section "Dummy Section" SecDummy2
 SetOutPath "$EXEDIR"
 ReadEnvStr $0 "ComSpec"
 ExecCmd::exec /TIMEOUT=10000 '"mysqladmin.exe -p -uroot reload" >mysql.log' "my_password$r$n"
 Pop $0 # return value - process exit code or error or still running.
 MessageBox MB_OK "Exit code $0"
SectionEnd
永恒心锁,版权所有丨如未注明,均为转载丨本网站采用BY-NC-SA协议进行授权

转载请注明:永恒心锁-分享互联网 » ExecCmd为NSIS提供了运行命令行不显示黑框的功能

您必须 登录 才能发表评论!