Old 19th March 2009, 08:39   #1
Junior Member
Join Date: Dec 2008
Posts: 39

I a lot of DOS comands, so i don't want to make for every command a batch-file with "pause", and later switch back to exec without batch-files. So, i search for a trick to make every ExecWait command output "visible" with a small extra command...
congahonga is offline   Reply With Quote
Old 19th March 2009, 13:37   #2
Major Dude
Comperio's Avatar
Join Date: Jan 2005
Location: Oregon Coast
Posts: 737
There may be another way, but if it where me, I might consider something like this:

Make your calling methods into a macro and place it in it's own header file (*.NSH).

Then, when you want to switch, you only need to rewrite your macro. (Your main script code could remain the same; you'd just switch header files.)

Examples of a macro:
; Dos window
!macro ExecMyCommand CustomExec command param
Exec 'cmd.exe /c "${command}" ${param}'

; no window
!macro ExecMyCommand CustomExec command param
nsExec::ExectoLog 'cmd.exe /c "${command}" ${param}'

Then in your main script:

!include myheader.nsh
!insertmacro ExecMyCommand "myfile.bat" "/d /a=p"

You could also tweak your macro to have both methods and insert the proper one based on another define. like:
!ifdef debug
; define old macro
; define new macro

Comperio is offline   Reply With Quote
Old 21st March 2009, 02:12   #3
Senior Member
Join Date: Mar 2008
Posts: 129
I'm not sure what your goal is, but I use ExecToStack for running command line/console mode tools during installation. This allows you access to everything that appeared in the console, as well as the return code. You could display this in a message box or log it to a file.
AaronLS is offline   Reply With Quote
Old 23rd March 2009, 08:40   #4
Junior Member
Join Date: Dec 2008
Posts: 39
Very easy way !

I found another VERY EASY way !

Instead of

ExecWait "setsu.exe $3 -s StandardUser -m KWO -d operational"

which doesn't prompt, even if an error occurs.

I use

ExecWait "cmd /c pause | setsu.exe $3 -s StandardUser -m KWO -d operational"

(setsu.exe is a special command as a file, that i use)

The trick is, that "cmd /c" means for the shell: execute only ONE command, then close.

"pause | setsu.exe" is a piped command (so it's in fact one command, even if it looks like two commands)

This is a trick to add a pause to every Shell-Command.

Attention: is not "<command> | pause", it's vice versa like above

I try to combine this trick with dependend compiling, so you can set one compiler directive and the output stops with pause (while developing) and you can cancel this function with one compiler directive !

When i found it out, i post it here for YOU ALL!

by the way: look in wikipedia for "cmd" there a quit a lot of very nice parameters, to expend shell functionalities. Perhaps you will need that !

Last edited by congahonga; 23rd March 2009 at 10:22.
congahonga is offline   Reply With Quote
Old 23rd March 2009, 10:32   #5
Junior Member
Join Date: Dec 2008
Posts: 39
That's it finally

Now you can switch between debug-mode with a break, and release mode without a break !
I didn't usw compiler-directives, I use an normal variable called DEBUG, that makes it.

Please reply my post, if you like my "dirty trick", because i want to find out, if i found out a good trick, or a bad one... :-)

Name "Test"
OutFile "Test.exe"

!include LogicLib.nsh

VAR cmd_prefix

Page instfiles


# 1 for debug-mode, 0 for release without breaks
push 1
pop $DEBUG

${If} $DEBUG == 0
StrCpy $cmd_prefix "cmd /c"
StrCpy $cmd_prefix "cmd /c pause |"

ExecWait "$cmd_prefix echo 1.Command simulated with echo"

ExecWait "$cmd_prefix echo 2.Command simulated with echo"

congahonga is offline   Reply With Quote
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump