Archive: ChDir missing? (Working directory / CurDir)


ChDir missing? (Working directory / CurDir)
Seems there is no built-in way of setting the current working directory (for installer process). Just copying a value to $OUTDIR does not work. I didn't try SetOutPath since this will create a directory (if missing) and maybe it just sets $OUTDIR, too.

I want to set the current working directory to something specific so I can use commands like FileOpen with relative paths. If the directory is missing the original working directory is a valid fallback.

Ideas?


To set the working directory you have to use SetOutPath indeed.
If you want to prevent the folder to be created, you have to check if the folder exists, and if not, SetOutPath to the original working directory.


Ok, seems that SetOutPath sets $OUTDIR, creates that directory if missing _and_ changes current working dir to that directory.

BTW: $OUTDIR is initially empty. Might need an API call to get the working directory at script start (GetCurrentDirectory).


Yes, you will need GetCurrentDirectory:
http://forums.winamp.com/showthread.php?postid=1973815


I just found some note in documentation of "Rename":

"If no absolute path is specified the current folder will be used. The current folder is the folder set using the last SetOutPath instruction. If you have not used SetOutPath the current folder is $EXEDIR."

I think something like this would be useful at documentation for $OUTDIR and especially SetOutPath. And it might be wrong since the working directory and $EXEDIR are generally NOT the same before using SetOutPath. So if "current folder" means the working directory the documentation is wrong.


Documentation for "FileOpen" has same comment, "RegDll" similar. Docs for "Exec", "ExecShell" and "CreateShortCut" should say what the working directory is if $OUTDIR is still empty.

The notion "current directory" is used for "File", too. But I guess this means the current working directory of makensis/makensisw process. This is not the working directory when starting makensis/makensisw but is the directory of the nsi file getting compiled.


To get the current working directory I use

 GetFullPathName $WORKING_DIR ".\"