Winamp & Shoutcast Forums

Winamp & Shoutcast Forums (http://forums.winamp.com/index.php)
-   NSIS Discussion (http://forums.winamp.com/forumdisplay.php?f=65)
-   -   Can't understand how stack works (http://forums.winamp.com/showthread.php?t=343749)

rumovoice 3rd April 2012 10:49

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 3rd April 2012 11:34

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.

pengyou 3rd April 2012 12:11

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

rumovoice 3rd April 2012 13:13

Thank you


All times are GMT. The time now is 17:34.

Copyright © 1999 - 2010 Nullsoft. All Rights Reserved.