Old 9th November 2004, 18:44   #1
mwiseman
Junior Member
 
Join Date: Nov 2004
Posts: 3
Difference between Exec and nsExec

Hello,

I'm trying to run an executable using nsExec. The run always ends in an error that indicates an executable-related error.

nsExec::ExecToLog '"myapp.exe"'

I can run the same executable using Exec without a problem.

Exec '"myapp.exe"'

Thinking that the environment may be the issue, I've tried:

nsExec::ExecToLog '<path_to_cmd.exe> /C "myapp.exe"'

to no avail. This problem seems to point to differences in how nsExec and Exec work but I don't know what they are. Any ideas?

Thanks,

Mike
mwiseman is offline   Reply With Quote
Old 9th November 2004, 19:15   #2
flizebogen
Senior Member
 
Join Date: Jan 2002
Location: Berlin
Posts: 172
nsexec was written for command line apps. With nsexec::ExecToLog you can capture the outpu of the app and display it in the result window.
As far as i know it doesn't support live output as used by programs like rar.
flizebogen is offline   Reply With Quote
Old 9th November 2004, 19:40   #3
mwiseman
Junior Member
 
Join Date: Nov 2004
Posts: 3
myapp.exe is a command line app:

c:\>myapp.exe

Writes to cmd.exe window and terminates.
mwiseman is offline   Reply With Quote
Old 9th November 2004, 20:51   #4
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
Something like this should work:

code:

!define LogFile "$INSTDIR\myapp_dump.txt"
Push $R0
ReadEnvStr $R0 COMSPEC
nsExec::Exec '$R0 /C "$INSTDIR\myapp.exe" > "${LogFile}"'
FileOpen $R0 "${LogFile}" r
LoopRead:
ClearErrors
FileRead $R0 $R1
IfErrors LoopDone
Push $R1
Call TrimNewLines
Pop $R1
DetailPrint $R1
Goto LoopRead
LoopDone:
FileClose $R0
Pop $R0
SetDetailsPrint none
Delete "${LogFile}"
SetDetailsPrint both



That would be another method of capturing the output.
Note that nsExec::Exec will run your application and hide it completely from the user (so the user will not see a command-prompt window.)

-Stu
Afrow UK is offline   Reply With Quote
Old 10th November 2004, 15:18   #5
mwiseman
Junior Member
 
Join Date: Nov 2004
Posts: 3
Thanks for the script but this doesn't really answer my question. I'm not looking for more error output from the nsExec run. The 'nsExec::ExecToLog' does write the errors to the result window. My question is: why would *any* command line program run to completion using:

Exec '"myapp.exe"'

but fail using:

nsExec::ExecToLog '"myapp.exe"'


I'll be more specific now: the app I'm trying to run is Microsoft's Baseline Security Analyzer utility: mbsacli.exe. The error I get seem to be network-related - 'no computer were found'.
mwiseman is offline   Reply With Quote
Old 10th November 2004, 16:48   #6
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
Well, as nsExec doesn't execute your program through COMSPEC then perhaps that's why it is failing. Maybe you have to run it through COMSPEC for it to work?

-Stu
Afrow UK is offline   Reply With Quote
Old 10th November 2004, 17:10   #7
Takhir
Major Dude
 
Join Date: Feb 2004
Location: Moscow, Russia
Posts: 1,222
Windows MS DOS (console) window is a bit more complex then a process with stdin and stdout only. Simple console applications work fine with nsExec, but some apps require more - terminal emulation or something else (like telnet does). This may be a reason, Exec creates full MS DOS console window, but nsExec simply redirects IO to pipes. You can also try ExecWait with SW_HIDE.
Takhir is offline   Reply With Quote
Old 12th January 2005, 13:51   #8
Comm@nder21
Major Dude
 
Join Date: Jul 2003
Location: germany, b-w
Posts: 734
Send a message via ICQ to Comm@nder21
Quote:
You can also try ExecWait with SW_HIDE.
does execwait support window state parameters like SW_HIDE ?

from the nsis docs:
Quote:
command [user_var(exit code)]
as i need to run a cmd-program in a loop, i need to get the installer wait until it has finished, but also to execute it in the backround without popping up the shell window everytime.

does nsExec::Exec do this, or is it possible to use SW_HIDE with ExecWait?
Comm@nder21 is offline   Reply With Quote
Old 12th January 2005, 15:51   #9
Takhir
Major Dude
 
Join Date: Feb 2004
Location: Moscow, Russia
Posts: 1,222
Yes, you are right, I probably had in mind ExecShell. IMHO one of DOS-exec plug-ins is a good decision in your situation.
Takhir is offline   Reply With Quote
Old 13th January 2005, 19:23   #10
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
It always complains about being unable to create a scan object for me. Can you attach a complete example for which you get the error you're talking about?

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Reply
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