Archive: nsExec is performing very slow


nsExec is performing very slow
I am using lot of already created exe files in my installer. I am prefering nsExec over exec as it allows me to redirect my output to the logfile. The problem is nsExec takes a long time to run and sometimes it is even not able to recover from minor errors, for which I have no Idea.
I would be very thankful if someone can shed light on this topic.

Thanks in advance,
Prabhat Jain.


Example script to prove my point
For Example run this nsi file on your computer.
It is a simple example of what I am pointing out. When I run this it does not take me to the completion point immediately. but takes a long time.

;nsis script begin----------

Name "nsExec Test"

OutFile "nsExec Test.exe"

ShowInstDetails show


Section "MakeNSIS commands help"
nsExec::ExecToLog "notepad"
;nsExec::ExecToLog '"${NSISDIR}\makensis.exe" /CMDHELP'
Pop $0 # return value/error/timeout
DetailPrint ""
DetailPrint " Return value: $0"
DetailPrint ""
SectionEnd

;nsis script ends----------


This is not a good example. Script execution will cease until you close notepad!

nsExec's sole purpose is for console applications anyway.

Stu


It is not about notepad
Notepad was just an example, my problem is whanever I am using nsExec it is not coming to the point of completion so that I can exit my installer properly, I have to kill the process from taskmanager. It is somehow not returning back.
Use rather this script, the same thing will
happen.

;NSI script begins--------------------------
Name "nsExec Test"

OutFile "nsExec Test.exe"

ShowInstDetails show


Section "MakeNSIS commands help"
nsExec::ExecToLog '"${NSISDIR}\makensis.exe" /CMDHELP'
Pop $0 # return value/error/timeout
DetailPrint ""
DetailPrint " Return value: $0"
DetailPrint ""
SectionEnd

;NSI script ends--------------------------


Hmm that worked fine for me. Returned in under a second. Latest NSIS version, Win XP SP2.

Stu


You are right it is working on Win XP SP2 correctly, I checked it on my laptop, but at my workplace we are using Windows Server 2003 sp2 and it is not working there. Did I found a Bug? I also have latest installation of NSIS(Installed it yesterday again).


Cannot be sure. Can you try out the ExecDos plugin?

Stu


Anything special with your Windows 2003? You're not the first, but I could never reproduce any report.


Thanks for the reply.
I have started using ExecDos::exec and it is working fine for now...
So no need for nsExec.

Prabhat.


Any chance you're going to donate information about this problem anyway?


nsExec::ExecToLog stalling without response.
Very confused, but the scenario seems to be along the lines of stack corruption. I can't be sure..... but I have a page that runs a nsExec::ExecToLog call and pops the result... and if I skip that segment.... the following page, ( the components page. ) actually progresses when I press the install button.....

But if I execute the call.... ( though it doesn't fail immediately ) after it completes, and I move on.. from the custom page into the component page...

( I track the entry into the component page with a pre or show popup box) and I track the exit with a MessageBox in the leave.....

Thing is.... when I press the Install button of the components, I never hit the leave function but I stall immediately. I put popups into each of my sections, and it never fires a section marker.....

This was stable code till yesturday when I added the nsExec::ExecToLog calls to the custom page leave function..... very strange.

The thing that makes me think its stack corruption is that it doesn't fail immediately, but fails later on an instrinsic page-move call... which are all stack critical.... it also seems to have corrupted the ability to go back....

Not saying that it couldn't be something else... ( and if I find it.... I will come back and disreguard this guess... ) but kitchic was looking for a straw to yank on.... maybe this is something...

_AWallo


You shouldn't be using ExecToLog unless you're running from a section anyway but that shouldn't cause any problems. Can you post a script that reproduces the problem?

Stu


No ExecToLog except in Section?
The script is huge... and won't run independantly.. ( i.e. if I snip ) but I was playing with my sequence, and I swapped for Exec and used a different $var to pop into, and then I went back to ExecLog but didn't change back the variable and the amazing page problem just went away.

. !insertmacro BIMAGE "BannerFindingRulebase.bmp" ""
SendMessage $HWNDPARENT ${WM_SETTEXT} 0 "STR:Downloading Rulebase:"

; Ok we're leaving but if we're using an existing rulebase, we still should test the s2check test for the new authentication string..

; This flag was determined on the previous page. Its
; defaulted in onInit and set on a custom page as it goes
; through. Essentially, if we're getting a new set of rules
; then we're going to do a lot of stuff on this screen
; which ( executed safe, further down. )
; but when the top branch fell through, it would hang
; two pages away.


StrCmp $UseDetectedRulebase "1" 0 GetTheRulebaseNow
; Ok, well do the s2check for concurrance....

; Poking around, messed with this.
; USED to use $var 9 but for some reason went to 0 and
; cleared it up.
;nsExec::ExecWait 's2check.exe $LicenseID.snf "$Authentication"' $9
;pop $9

; Then when we went back to this
; it didn't have a problem.

nsExec::ExecToLog '"$InstallDir\$FolderPrefix\snf2check.exe" $LicenseID.snf "$Authentication"'

pop $0

StrCpy $s2Check $0 ; Set this as a flag for the message for the next screen, or if we just pass through. ( 0 result is clean )
Return ; ignore displaying this screen.....

;Otherwise

GetTheRulebaseNow:
; Else download and report.
nsDialogs::Create /NOUNLOAD 1018
Pop $0 ; All my screens tend to pop $0 for the Nounload temp var...


Just so we're clear. The script portion that I'm editing was two pages away from the place in the code that froze.

And the malfunction in the script occurred when you clicked on <Back> or <install>. Then it became unresponsive. Just because of something with

nsExec:ExecToLog "blah blah blah"
pop $9

Which when I moved the pop to $0 viola...... problem dissappeared.

Now, None of my code depends on $vars 0-9 being stable. i.e. I only use them for temp vars. And YES I looked for something depending on $9 for something else.... but it was not to be.

So..... Now please elaborate why I can't use ExecToLog in my custom pages?


Because ExecToLog writes STDOUT to the install log window. Obviously you don't have an install log window when you are in a custom page!

Use nsExec::Exec or nsExec::ExecToStack. However, as I said before, this shouldn't be causing a problem.

Stu


Reason why nsExec::Exec is slow
Hi, I work for Mozilla and we recently had a bug report that Microsoft Security Essentials caused one of our files to act very slowly on updates and downloads while it scanned the file.

I could reproduce consistently. We narrowed down the slowness to be from nsExec::Exec. Replacing with ExecWait fixed the problem, but of course it has command prompts popup now. I then searched to see if anyone else had this problem and found this thread.


....
Also I should add that you have to have a silent installer for this to happen. Also I know this is a really old topic but just in case someone else finds this thread :)


Hmm. I haven't seen that problem with my installers.

Our main product installer uses NsExec:Exec 9 times. This installer is run silent via /S. There are 8 times I use that in an outer meta-installer (which is not run silently). Other installers we run during our product installation have 7 NsExec calls during TFTP install and 2 more in another component installer (these are run with /S, too). I also use that in other utilities that aren't a normal part of our product.

Our product is run on a dedicated PC included with our system (HW & SW). Until this month we've been using Windows 2000. We tested Windows 7 last year and are just now releasing new systems with that OS. A small number of installations have been done by our developers or other inhouse personnel on Windows XP. I've never seen or received reports of the installer hanging or the program that was Exec'ed not ending properly. We have about 15000 customers, most have had the software installed many times as we upgrade to new versions.


I have always used the ExecDos plug-in because of it's better output-to-stack support. Also I have had an issue with nsExec in the past on systems that have AntiExecutable or similar software installed - nsExec appears to create its own temporary process under a random name which is always blocked.

Stu


The /S option
The problem doesn't happen with the /S option. That's actually how we're fixing the problem, to have a UI and to use the /S option. MS Security Essentials Real time scan option seems to trigger some longer than normal scan when data is read or written from disk, when the installer is silent and there is a call to nsExec::Exec.

You can only reproduce if you have both of the above conditions.