ShellExecWait: Difference between revisions
From NSIS Wiki
Jump to navigationJump to search
No edit summary |
(a macro now) |
||
Line 1: | Line 1: | ||
{{PageAuthor|Anders}} | {{PageAuthor|Anders}} | ||
[[Category:Functions & Macros]] | |||
Basic code for waiting on a "ExecShell" (Note that you can only wait on programs, not documents or URL's) | Basic code for waiting on a "ExecShell" (Note that you can only wait on programs, not documents or URL's) | ||
Line 7: | Line 8: | ||
!include WinMessages.nsh | !include WinMessages.nsh | ||
!macro ShellExecWait verb app param workdir show exitoutvar ;only app and show must be != "", every thing else is optional | |||
#define SEE_MASK_NOCLOSEPROCESS 0x40 | #define SEE_MASK_NOCLOSEPROCESS 0x40 | ||
System::Store S | |||
System::Call '*(&i60)i.r0' | System::Call '*(&i60)i.r0' | ||
System::Call '*$0(i 60,i 0x40,i $hwndparent, | System::Call '*$0(i 60,i 0x40,i $hwndparent,t "${verb}",t "${app}",t "${param}",t "${workdir}",i ${show})i.r0' | ||
System::Call 'shell32::ShellExecuteEx(ir0)i.r1 ?e' | System::Call 'shell32::ShellExecuteEx(ir0)i.r1 ?e' | ||
${If} $1 <> 0 | ${If} $1 <> 0 | ||
System::Call '*$0(is,i,i,i,i,i,i,i,i,i,i,i,i,i,i.r1)' ;stack value not really used, just a fancy pop ;) | System::Call '*$0(is,i,i,i,i,i,i,i,i,i,i,i,i,i,i.r1)' ;stack value not really used, just a fancy pop ;) | ||
System::Call 'kernel32::WaitForSingleObject(ir1,i-1)' | System::Call 'kernel32::WaitForSingleObject(ir1,i-1)' | ||
System::Call 'kernel32::GetExitCodeProcess( | System::Call 'kernel32::GetExitCodeProcess(ir1,*i.s)' | ||
System::Call 'kernel32::CloseHandle( | System::Call 'kernel32::CloseHandle(ir1)' | ||
${EndIf} | ${EndIf} | ||
System::Free $0 | System::Free $0 | ||
!if "${exitoutvar}" == "" | |||
pop $0 | |||
!endif | |||
System::Store L | |||
!if "${exitoutvar}" != "" | |||
pop ${exitoutvar} | |||
!endif | |||
!macroend | |||
</highlight-nsis> | |||
<highlight-nsis> | |||
!insertmacro ShellExecWait "" "notepad.exe" "c:\config.sys" "" ${SW_SHOW} $1 | |||
MessageBox mb_ok "exitcode or error=$1" | MessageBox mb_ok "exitcode or error=$1" | ||
</highlight-nsis> | </highlight-nsis> |
Revision as of 19:32, 29 March 2010
Author: Anders (talk, contrib) |
Basic code for waiting on a "ExecShell" (Note that you can only wait on programs, not documents or URL's)
!include LogicLib.nsh !include WinMessages.nsh !macro ShellExecWait verb app param workdir show exitoutvar ;only app and show must be != "", every thing else is optional #define SEE_MASK_NOCLOSEPROCESS 0x40 System::Store S System::Call '*(&i60)i.r0' System::Call '*$0(i 60,i 0x40,i $hwndparent,t "${verb}",t "${app}",t "${param}",t "${workdir}",i ${show})i.r0' System::Call 'shell32::ShellExecuteEx(ir0)i.r1 ?e' ${If} $1 <> 0 System::Call '*$0(is,i,i,i,i,i,i,i,i,i,i,i,i,i,i.r1)' ;stack value not really used, just a fancy pop ;) System::Call 'kernel32::WaitForSingleObject(ir1,i-1)' System::Call 'kernel32::GetExitCodeProcess(ir1,*i.s)' System::Call 'kernel32::CloseHandle(ir1)' ${EndIf} System::Free $0 !if "${exitoutvar}" == "" pop $0 !endif System::Store L !if "${exitoutvar}" != "" pop ${exitoutvar} !endif !macroend
!insertmacro ShellExecWait "" "notepad.exe" "c:\config.sys" "" ${SW_SHOW} $1 MessageBox mb_ok "exitcode or error=$1"