Old 3rd April 2012, 10:49   #1
rumovoice
Junior Member
 
Join Date: Nov 2011
Posts: 11
Can't understand how stack works

I've written following function:
code:
Function KillMyProcess
; Change current directory to temp
; to prevent creation of TempWmicBatchFile.bat
Push $OUTDIR
StrCpy $OUTDIR $TEMP
nsexec::ExecToLog "wmic process where name='MyApp.exe' delete"
Pop $OUTDIR
FunctionEnd



As far as I know $OUTDIR should not change after this function is called, but it equals to 0 instead. I tried to add debug message boxes. Looks like everything goes fine until Pop is called which just sets $OUTDIR value to zero. Why is that?
rumovoice is offline   Reply With Quote
Old 3rd April 2012, 11:34   #2
rumovoice
Junior Member
 
Join Date: Nov 2011
Posts: 11
And also I've discovered that changing $OUTDIR on a page before instfiles does not help. Looks like it do not change current directory before instfiles.
rumovoice is offline   Reply With Quote
Old 3rd April 2012, 12:11   #3
pengyou
Major Dude
 
Join Date: Mar 2003
Posts: 571
From the documentation for the nsExec plugin:
Quote:
If nsExec is unable to execute the process, it will return "error" on the top of the stack, if the process timed out it will return "timeout", else it will return the return code from the executed process.
So your code is putting the return value from nsExec into $OUTDIR and leaving the original value still on the stack. You need to use another Pop command to retrieve the $OUTDIR value you saved on the stack.

There is a wiki page that has some information about how the stack works:
http://nsis.sourceforge.net/Pop,_Pus...h..._The_Stack
pengyou is offline   Reply With Quote
Old 3rd April 2012, 13:13   #4
rumovoice
Junior Member
 
Join Date: Nov 2011
Posts: 11
Thank you
rumovoice 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