CmdExec: Difference between revisions
From NSIS Wiki
Jump to navigationJump to search
m (added stay mode) |
m (→Macro) |
||
Line 14: | Line 14: | ||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
!define Cmd "!insertmacro _CmdExec 0" ; nopause/nowait | !define Cmd "!insertmacro _CmdExec 0" ; nopause/nowait | ||
!define | !define CmdWait "!insertmacro _CmdExec 1" ; execwait | ||
!define | !define CmdPause "!insertmacro _CmdExec 2" ; dospause | ||
!define CmdPauseWait "!insertmacro _CmdExec 3" ; dospause+execwait | !define CmdPauseWait "!insertmacro _CmdExec 3" ; dospause+execwait | ||
!define CmdStay "!insertmacro _CmdExec 4" ; stay in command | !define CmdStay "!insertmacro _CmdExec 4" ; stay in command prompt | ||
!define CmdStayWait "!insertmacro _CmdExec 5" ; stay | !define CmdStayWait "!insertmacro _CmdExec 5" ; stay+execwait | ||
;; | |||
!macro _CmdExec _Mode_ _WorkDir_ _CommandAndParams_ | !macro _CmdExec _Mode_ _WorkDir_ _CommandAndParams_ | ||
StrCmp "${_WorkDir_}" "" +3 | StrCmp "${_WorkDir_}" "" +3 | ||
Line 24: | Line 25: | ||
SetOutPath "${_WorkDir_}" | SetOutPath "${_WorkDir_}" | ||
!if '${_Mode_}' == '1' | !if '${_Mode_}' == '1' | ||
ExecWait `"$SYSDIR\cmd.exe" /c "${_CommandAndParams_}"` | |||
!else if '${_Mode_}' == '2' | |||
Exec `"$SYSDIR\cmd.exe" /c "${_CommandAndParams_}" & echo. & echo. & pause` | Exec `"$SYSDIR\cmd.exe" /c "${_CommandAndParams_}" & echo. & echo. & pause` | ||
!else if '${_Mode_}' == '3' | !else if '${_Mode_}' == '3' | ||
ExecWait `"$SYSDIR\cmd.exe" /c "${_CommandAndParams_}" & echo. & echo. & pause` | ExecWait `"$SYSDIR\cmd.exe" /c "${_CommandAndParams_}" & echo. & echo. & pause` |
Revision as of 17:54, 4 February 2012
Author: Lloigor (talk, contrib) |
Description
Execute a command with cmd.exe, with optional dospause and execwait.
Example
${CmdPause} `$ParentFolder` `"d:\tools\free_upx\upx.exe" -v --brute $FileNames`
Macro
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Execute a command with cmd.exe ;; P1 :in: Working directory (""=$outdir) ;; P2 :in: Command and parameters ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; !define Cmd "!insertmacro _CmdExec 0" ; nopause/nowait !define CmdWait "!insertmacro _CmdExec 1" ; execwait !define CmdPause "!insertmacro _CmdExec 2" ; dospause !define CmdPauseWait "!insertmacro _CmdExec 3" ; dospause+execwait !define CmdStay "!insertmacro _CmdExec 4" ; stay in command prompt !define CmdStayWait "!insertmacro _CmdExec 5" ; stay+execwait ;; !macro _CmdExec _Mode_ _WorkDir_ _CommandAndParams_ StrCmp "${_WorkDir_}" "" +3 Push $OutDir SetOutPath "${_WorkDir_}" !if '${_Mode_}' == '1' ExecWait `"$SYSDIR\cmd.exe" /c "${_CommandAndParams_}"` !else if '${_Mode_}' == '2' Exec `"$SYSDIR\cmd.exe" /c "${_CommandAndParams_}" & echo. & echo. & pause` !else if '${_Mode_}' == '3' ExecWait `"$SYSDIR\cmd.exe" /c "${_CommandAndParams_}" & echo. & echo. & pause` !else if '${_Mode_}' == '4' Exec `"$SYSDIR\cmd.exe" /k "${_CommandAndParams_}"` !else if '${_Mode_}' == '5' ExecWait `"$SYSDIR\cmd.exe" /k "${_CommandAndParams_}"` !else Exec `"$SYSDIR\cmd.exe" /c "${_CommandAndParams_}"` !endif StrCmp "${_WorkDir_}" "" +4 Exch $R0 SetOutPath "$R0" Pop $R0 !macroend