Migrate from GitHub to SourceForge with this tool. Check out all of SourceForge's recent improvements.

#1055 SetOutPath doesn't work with drive root

2.0 Series
General (291)

1. InitPluginsDir
2. CreateDirectory "$PLUGINSDIR\test"
3. SetOutPath "$PLUGINSDIR\test"
4. SetOutPath "C:\"
5. RMDir /r "$PLUGINSDIR\test"

Line 5 will set the error flag and process explorer reports that the installer is still locking the test directory.
$OUTDIR is set to "C:" and File commands work, however.

If you change line 4 to `SetOutPath $PLUGINSDIR`, then everything works fine and the test directory gets deleted.

NSIS 2.46 standard official non-unicode build


  • Marshall

    Marshall - 2012-07-18

    Forgot to mention, tested on Windows 7 Professional x64.

  • Anders

    Anders - 2012-07-27

    NSIS chops off the final \ so when you call SetOutPath "C:\" that ends up calling kernel32!SetCurrentDirectoryA with "C:" and that does not change the real current path that the process has a open handle to.

    You could work around it by using SetOutPath "c:\." but this is not really a good idea either because you don't know if the end user has a c: drive in the first place.

    You should use a known good location, SetOutPath "$temp" etc

  • Anders

    Anders - 2012-07-27

    SetOutPath "\." also seems to work if you really really need the current directory to be the root of a drive. Note that it sets $outdir to a relative path so you should probably call GetFullPathName $outdir $outdir before using $outdir as a path to something...

  • Marshall

    Marshall - 2013-05-11

    I discovered this due to a user downloading the installer and running it from drive root, and we set the default location for a log file to $EXEDIR

    Problem occurs without us ever knowingly specifying root. It did cause us problems with files/folders getting left behind. The user may have many ways of giving us a root path ($EXEDIR, a config file, directory selection page) and so we have to write a wrapper around SetOutPath to check for drive root and implement a workaround.


Log in to post a comment.