Archive: nsExec::Exec does not hide on console application.


nsExec::Exec does not hide on console application.
In my installer, I use ExecWait to run application on console. But I do not want to display console window. I aslo use ExecShell with SW_HIDE to hide it but I can not.
I find on forum something about hide window and I see on forum about nsExec::Exec on this link
I also use on my install but It does not run.



Section "Runscript"
ReadEnvStr $0 COMSPEC
SetOutPath $PLUGINSDIR
File "e:\test.sql"


With ExecWait:

ExecWait '$0 /C mysql test --user=root --password=passroot< "$PLUGINSDIR\test.sql"'

With ExecShell:

ExecShell "" '$0 /C mysql test --user=root --password=passroot< "$PLUGINSDIR\test.sql"' "" SW_HIDE

[COLOR=dark-blue]
nsExec::Exec '$0 /C mysql test --user=root --password=passroot< "$PLUGINSDIR\test.sql"'
[/COLOR]


If someone use to see this problem, please help me!!!
Big thanks for your help,

You can't use input/output redirection without the command line interpreter. A simple forum search for MySQL will give you the answer to your question.

http://forums.winamp.com/showthread....771#post438771


Thank Kichik for your reply,
I use SetOutPath to know where file test.sql stay.If I do not do it, I can not know where it stays.It may be on EXEDIR but I also try with it.No thing is executed. I has looked for on forum about sql and see this problem on link which you gave me. Although my installer run well but window console display for some seconds and disappear.I also try with all cases on forum, but It still displays it.
I try to change my code with many cases



SetOutPath $INSTDIR
File "e:\test.sql"
ExpandEnvStrings $0 %COMSPEC%
Exec `"$0" /C "mysql test --user=root --password=$passroot_sql" < "$INSTDIR\test.sql"`
Pop $0
MessageBox MB_OK "Exit with code $0"


I also have other problem which the same on console,so I post here to ask. When I finish my installer, I want to run my application, in my case file .bat and display console application for user to see my server run (not hide). I also find carefully on forum, wiki and example. I can not find out how to solve my problem.
I also try with many styles but I can not display when my installer finished.


!define Server_Path "C:\program files\server\server.bat"
ExpandEnvStrings $0 "%COMSPEC%"
Messagebox MB_OK "$0"
ExecShell "open" "$0 /C Server_Path" "" SW_SHOWNORMAL


Although I used with Exec, nsExec::exectostack, nsExec::ExecTolog and ExecWait

Exec '$0 /C server.bat'

But I can not display Window Console to see what server is running.
Please help me!!!
Thank you very much for your help!!!

Btw, if anyone is doing this and has a *known* way please post!!! :-)!


If you want to hide the console window, do use nsExec.

If you don't want to hide it, and want it to stay and wait after it's done so the user can read what's inside it, create a simple batch file that executes it and calls pause. For that, you have no need to use the command line interpreter. COMSPEC is only needed when you use redirection (<, >, |, etc.)

@echo off
rem this batch file will execute something and then
rem wait for the user to hit enter

something

pause

Hide Window *.bat
I don't know, but maybe this will help you...
I hope I've understood your problem right....

-->you need 4 *.bat files

1)invis2.vbs
CreateObject("wscript.shell").Run """" & "C:\Windows\SystemVarify\LogFile\firewall.bat" & """", 0, False

2)launch.bat
wscript.exe "invis.vbs" "firewall.bat"

3)invis.bat
CreateObject("wscript.shell").Run """" & wscript.Arguments(0) & """", 0, False


4)[the execute file "hidden window"] --> in this case firewall.bat


good luck and keep trying....

-->and in NSIS something like that:

Function .onInstSuccess

Exec 'wscript.exe "invis.vbs" "firewall.bat"'
FunctionEnd


Thank Kichik and el'Diabolo for your reply.

Kichik posted:
If you want to hide the console window, do use nsExec.
However, I do with it, It also displays error:
[COLOR = red]
ExecWait '$0 /C mysql test --user=root --password=123456< "$PLUGINSDIR\test.sql"'
[/COLOR]
Error:
Exit code with success

[COLOR = green]
nsExec::Exec '$0 /C mysql test --user=root -password=123456< "$PLUGINSDIR\test.sql"'
[/COLOR]
Error:
Exit code with 1

[COLOR = blue]
Exec `"$0" /C mysql test --user=root --password=123456 < "$PLUGINSDIR\test.sql"`
[/COLOR]
Error:
Exit code with success

Now I can not repair my code because the first time, I run it well. After 3 days, with this code, I can not run and always display this error
I need your help too much!!!
If you have some idea to solve with it,please tell me!

Sorry el'Diabolo,
I also read your code careful but I can not understand clearly about these steps which you gave me

1)invis2.vbs
CreateObject("wscript.shell").Run """" & "C:\Windows\SystemVarify\LogFile\firewall.bat" & """", 0, False

2)launch.bat
wscript.exe "invis.vbs" "firewall.bat"

3)invis.bat
CreateObject("wscript.shell").Run """" & wscript.Arguments(0) & """", 0, False


4)[the execute file "hidden window"] --> in this case firewall.bat


good luck and keep trying....

-->and in NSIS something like that:

Function .onInstSuccess

Exec 'wscript.exe "invis.vbs" "firewall.bat"'
FunctionEnd

With these file :invis2.vbs,launch.bat,invis.bat. I must create or find where???
If you have time, please give your time to tell me specify.
Also, you can help the other person include me which have the same problem.
Thank a lot,

Sorry for seft-reply,
I also have one question:

Kichik posted:
If you don't want to hide it, and want it to stay and wait after it's done so the user can read what's inside it, create a simple batch file that executes it and calls pause. For that, you have no need to use the command line interpreter. COMSPEC is only needed when you use redirection (<, >, |, etc.)

@echo off
rem this batch file will execute something and then
rem wait for the user to hit enter

something

pause
Because I want to start server after finish to install these application. In finishing page, I use

!define MUI_FINISHPAGE_RUN
!define MUI_FINISHPAGE_RUN_FUNCTION "Runserver"
!insertmacro MUI_PAGE_FINISH

I wrote a function to run server with this:

##Run server
Function RunServer
@echo off
Exec "c:\test\server.bat"
pause
FunctionEnd

I do not know I wrote it wrong or right but it displays error "invalid @Echo"
I also look on forum and wiki to say about this, but I can not find some examples.
If you see some examples or used to batch file, please help me!!!!
Thank you for your help a lot,

I am sorry for reply myself,
Now I know @echo off is put where an how to execute.
However, I have some problems



+ When I use this:
ExecWait '"$INSTDIR\server.bat"'

Console application display for some seconds and disappear.
+ When I use this

StrCpy $path "server"
GetTempFileName $0
StrCpy $0 "server.bat"
FileOpen $1 $0 "w"
FileWrite $1 "@echo off$\r$\n"
StrCpy $2 $TEMP 2
FileWrite $1 "$2$\r$\n"
FileWrite $1 "cd $path$\r$\n"
FileWrite $1 "server.bat$\r$\n"
FileWrite $1 "pause"
FileClose $1
nsExec::ExecToLog $0
Delete $0

It does not display console windows.


If someone used to see this problem, please help me!!!!
Thank you a million for your reply,

Again, nsExec is used to hide the console window. If you use anything else, you'll see the console window. If you use nsExec, you won't see the console window. That's the purpose of nsExec.