Archive: RMDir has no effect


RMDir has no effect
Hi. My installer must create a shortcut to a file that does not yet exist. further more, the directory which eventually contains the file CANNOT exist after the installation. currently i am attempting to achieve this behaviour with the following script:

SetOutPath "$INSTDIR\webapps\xxx\WEB-INF"
CreateShortCut "$SMPROGRAMS\XXX Documents\Export or Import Database.lnk" \
"$INSTDIR\webapps\xxx\WEB-INF\guiexportimport.bat" \
"" \
"$INSTDIR\xxx.ico" 0 SW_SHOWNORMAL
; Remove directory created by SetOutPath
RMDir /r "$INSTDIR\webapps\xxx"
problem is the RMDir has no effect and the xxx directory still exists after the installation has completed. (the WEB-INF dir under xxx also exists). does anyone know what i am doing wrong?

Are you saying the shortcut is actually being created? (that would really surprise me, especially when you say that you must create a shortcut to file that does not exist.)

Assuming that the target really does exist (and that you have sufficiet rights to the shortcut directory), then as a test, I'd try to insert some "IfErrors" commands after the CreateShortcut and RMDir commands to see if either is returning an error.


yes, the shortcut was being created, even though the file did not exist (i agree the documentation says it shouldn't have been created).

i was originally using 2.04 and i have just tested the script (unchanged) with 2.05 and 2.0
2.04 > problem
2.05 > problem
2.0 > no problem

so the bug was arose due to upgrade from 2.0 to 2.04. is this a regression?

today was the first time i ran the script but the guy who wrote it was using 2.0 so that explains why it only just appeared.


bug logged (1118369)


This is not a bug. Windows not allows to delete current folder of applications. Following works on my comp


SetOutPath "$INSTDIR\webapps\xxx\WEB-INF"
; ...
SetOutPath $INSTDIR
RMDir /r "$INSTDIR\webapps\xxx"

NSIS approach to "outpath" might be changed in later versions.