ExecDos plug-in: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
No edit summary
Line 7: Line 7:


== Description ==
== Description ==
Plug-in works with console applications - creates hidden child process with redirected i/o. Compare to NSISdl has one add-on: string parameter that serves as stdin for running application. May be useful if you want to give login/password to running application. String size may be up to 8kB in the special NSIS build, 1 kB max otherwise. Usage:
Plug-in works with console applications - creates hidden child process with redirected i/o. Compare to NSISdl has two add-ons: 1) string parameter that serves as stdin for running application; 2) Async (background) process launch. First may be useful if you want to give login/password to running application, second - for long running applications. Plug-in puts log to file instead of 'detailed' installer window (optional). Maximim input string size is 8kB in the special NSIS build, 1 kB otherwise. Usage:
== How To Use ==
== How To Use ==
<highlight-nsis>
<highlight-nsis>
execDos::exec [/TIMEOUT=xxx] application_to_run [stdin_string] [log_file_name]
ExecDos::exec [/NOUNLOAD /ASYNC] [/TIMEOUT=xxx] application_to_run [stdin_string] [log_file_name]
</highlight-nsis>
</highlight-nsis>
; ASYNC
: Not waits for process exit. Use 'wait' call if you want to get exit code
; TIMEOUT
; TIMEOUT
: TOTAL execution time, milliseconds, for example /TIMEOUT=10000. Default is big enough. Short timeouts may cause app to be terminated.
: TOTAL execution time, milliseconds, for example /TIMEOUT=10000. Default is big enough. Short timeouts may cause app to be terminated.
Line 19: Line 21:
: all that application can get from stdin (optional, use "" if stack is not empty)
: all that application can get from stdin (optional, use "" if stack is not empty)
; log_file_name
; log_file_name
: file where to put app's stdout (optional, use "" if stack is not empty)
: file where to put app's stdout (optional, but use "" if stack is not empty)


== Example ==
== Example ==
<highlight-nsis>
<highlight-nsis>
execDos::exec /TIMEOUT=2000 "$EXEDIR\consApp.exe" "test_login$\ntest_pwd$\n" "$EXEDIR\execdos.log"
ExecDos::exec /TIMEOUT=2000 "$EXEDIR\consApp.exe" "test_login$\ntest_pwd$\n" "$EXEDIR\execdos.log"
Pop $0 # return value
Pop $0 # return value
MessageBox MB_OK "Exit code $0"
MessageBox MB_OK "Exit code $0"
Line 29: Line 31:
or
or
<highlight-nsis>
<highlight-nsis>
execDos::exec "$EXEDIR\consApp.exe" "" "$EXEDIR\execdoslog"
ExecDos::exec /NOUNLOAD /ASYNC "$EXEDIR\consApp.exe" "test_login$\ntest_pwd$\n" "$EXEDIR\execdos.log"
execDos::exec "$EXEDIR\consApp.exe"
ExecDos::wait
Pop $0 # return value
MessageBox MB_OK "Exit code $0"
</highlight-nsis>
or
<highlight-nsis>
ExecDos::exec "$EXEDIR\consApp.exe" "" ""
Pop $0 # return value
MessageBox MB_OK "Exit code $0"
</highlight-nsis>
</highlight-nsis>
'''BAT files specifics.''' On some of Win98 systems where "Close on exit" option is not set for DOS apps it was found that after '''batch''' execution was finished (and installer continue it's job) hidden window still remains in the system as "winoldapp". Following two lines solve the problem
'''BAT files specifics.''' On some of Win98 systems where "Close on exit" option is not set for DOS apps it was found that after '''batch''' execution was finished (and installer continue it's job) hidden window still remains in the system as "winoldapp". Following two lines solve the problem

Revision as of 11:05, 23 July 2005

Author: Takhir (talk, contrib)


Links

Download:
ExecDos.zip (40 KB)
Forum thread

Description

Plug-in works with console applications - creates hidden child process with redirected i/o. Compare to NSISdl has two add-ons: 1) string parameter that serves as stdin for running application; 2) Async (background) process launch. First may be useful if you want to give login/password to running application, second - for long running applications. Plug-in puts log to file instead of 'detailed' installer window (optional). Maximim input string size is 8kB in the special NSIS build, 1 kB otherwise. Usage:

How To Use

ExecDos::exec [/NOUNLOAD /ASYNC] [/TIMEOUT=xxx] application_to_run [stdin_string] [log_file_name]
ASYNC
Not waits for process exit. Use 'wait' call if you want to get exit code
TIMEOUT
TOTAL execution time, milliseconds, for example /TIMEOUT=10000. Default is big enough. Short timeouts may cause app to be terminated.
application_to_run
application to run.
stdin_string
all that application can get from stdin (optional, use "" if stack is not empty)
log_file_name
file where to put app's stdout (optional, but use "" if stack is not empty)

Example

ExecDos::exec /TIMEOUT=2000 "$EXEDIR\consApp.exe" "test_login$\ntest_pwd$\n" "$EXEDIR\execdos.log"
Pop $0 # return value
MessageBox MB_OK "Exit code $0"

or

ExecDos::exec /NOUNLOAD /ASYNC "$EXEDIR\consApp.exe" "test_login$\ntest_pwd$\n" "$EXEDIR\execdos.log"
ExecDos::wait
Pop $0 # return value
MessageBox MB_OK "Exit code $0"

or

ExecDos::exec "$EXEDIR\consApp.exe" "" ""
Pop $0 # return value
MessageBox MB_OK "Exit code $0"

BAT files specifics. On some of Win98 systems where "Close on exit" option is not set for DOS apps it was found that after batch execution was finished (and installer continue it's job) hidden window still remains in the system as "winoldapp". Following two lines solve the problem

@echo off
# place your code here
cls

Telnet and ssh Plug-in not works with applications requiring terminal emulation.