Archive: execwait and batch-files


execwait and batch-files
hello everyone,

i'm new to nsis and i'm delaing with it several days. it's impressing how easy nsis is handeled.

today i ran into a problem concerning the execwait command with executing batchfiles. this doesn't work for me.

i tried many times after searching the forum here for hints. all hints seem to be logic for me, unfortunately doesn't work.

here is my problem-code:

Execwait "$instdir\mplot\cmd.win\madmin.bat"

also tried with using comspec-env var and nsexec and this

Exec 'start /wait "$instdir\mplot\cmd.win\madmin.cmd"'

as suggested here in the forum.

the batchfile contents:

setlocal
set MQUEST_INSTL=C:\Ideas\IdeasNX\mplot
set MQUEST_SHARED=%MQUEST_INSTL%\bin\i686_nt
call "%MQUEST_INSTL%\cmd.win\mquest_varbs.cmd"
start "Title" "%MQUEST_SHARED%\mqxwish.exe" "%MQUEST_INSTL%\madmin\madmin.mqx" -- %*
endlocal


i also tried programming the lines directly into nsis-script - also not working:

SetOutPath "$INSTDIR\mplot\cmd.win"
exec "setlocal"
Exec "set MQUEST_INSTL=C:\Ideas\IdeasNX\mplot"
Exec "set MQUEST_SHARED=%MQUEST_INSTL%\bin\i686_nt"
SetOutPath "$INSTDIR\mplot\cmd.win"
Exec "$instdir\mplot\cmd.win\mquest_varbs.cmd"
SetOutPath "$INSTDIR\bin\i686_nt"
Execwait '"%MQUEST_SHARED%\mqxwish.exe" "%MQUEST_INSTL%\madmin\madmin.mqx"'
Exec "endlocal"


i don't know if there is any command which checks a certain process. this could do the job. the exe-file above is the important thing to me. maybe i have an error in the code above? if yes - sorry for that but i can't see the anything wrong.


i noticed that a 'pause' command is the only thing which really make nsis waiting.


thanks in advance for your help.

greetings
simplex


Can you explain what not works? mqxwish.exe not starts? With nsExec you can use ExecToLog to see batch output. And ExecDos also can redirect output to file. BTW Exec "set.. not works, because set is not an executable file but command line processor directive. This may help http://nsis.sourceforge.net/Setting_...ment_Variables


hello takhir,

thank you for your support.

mqxwish.exe always starts but installer finishes always before closing the exe.program.

i also tried execdos but without success.



the link you postet i quite good. i gave it a try and wrote following code with including WriteEnvStr.nsh as listed on that page:

!define ALL_USERS
!include WriteEnvStr.nsh # or the name you chose

Function startmadmin

Push "MQUEST_INSTL"
Push "$instdir\mplot"
Call WriteEnvStr
Push "MQUEST_SHARED"
Push "$instdir\mplot\bin\i686_nt"
Call WriteEnvStr

Execwait '"$instdir\mplot\bin\i686_nt\mqxwish.exe" "$instdir\mplot\madmin\madmin.mqx"'

FunctionEnd


nsis waits for the mqxwish.exe but the exe can't read the env-vars.

any suggestions?


Sorry, I had doubts when wrote previous post, but now I found this in MSDN : "The SetEnvironmentVariable function sets the value of an environment variable for the current process." And finally I cannot understand the idea of WriteEnvStr (using kernel32::SetEnvironmentVariable).
So the problem is following: installer not waits for batch file exit? May be mqxwish.exe starts some other application?


So the problem is following: installer not waits for batch file exit? -> correct.

the strange thing is that with the writeenvstr funtcion the env-vars schould be set even the machine is rebooted. this says the description: http://nsis.sourceforge.net/Setting_...ment_Variables
please see the paragraph between the first two code-segments.

May be mqxwish.exe starts some other application? ->
mqxwish.exe is a kind of command shell which starts an special script file (madmin.mqx). that's why the command line is executed with this parameter: "$instdir\mplot\madmin\madmin.mqx"

task manager says no other program is running when mqxwish.exe does.


another idea of mine was to compile the batch file to an com or exe-file and wait for this. i tried with sharware program which can do such a compilation. and it works -

BUT

there is always either an advertisement showing up or the user has to press a button to continue - that is not acceptabel for me.
btw do you know batch compilers which are open source or freeware?

this would be an alternative way and the nsis-command is an "easy-going".

greetings,

simplex


solution!
hello again takhir,

i've a solution right now!

it's quite simple but never thought about:

in the batch-file there is already a commandline "start" - this command supports the internal switch "/wait".

whole command in the batch-file looks like this:

start /wait "Title" "%MQUEST_SHARED%\mqxwish.exe" "%MQUEST_INSTL%\madmin\madmin.mqx" -- %*

and it works!


inspite, many thanks for your support.

greetings!


No I see :)
Your batch file launches mqxwish.exe in the new window (with new cmd) and this is why first cmd not waits. Are you sure this is really need? Or you want to start 2 applications?


hello again,

sorry for my absence.

in the meantime i completed the installer and all works fine.

the command line i mentioned in my last post is correct/necessary. i tried many situations but this is the only thing which works.

thanx

simplex