|
|||||||
![]() |
|
|
Thread Tools | Search this Thread | Display Modes |
|
|
#1 |
|
Junior Member
Join Date: Apr 2009
Posts: 25
|
How to remove only empty folder using IfFileExists function?
Hi,
I am trying to write an uninstall part where i remove empty folder and i bumped to a solution using IfFileExists but i don't know what am i doing wrong. Here is my code: IfFileExists "$SMPROGRAMS\${company}\*.*" StartMenuIsntEmpty StartMenuIsEmpty StartMenuIsEmpty: MessageBox MB_OK "$SMPROGRAMS\${company} is empty" RMDir /r /REBOOTOK "$SMPROGRAMS\${company}" GOTO EndOfCheckIfStartMenuIsEmpty StartMenuIsntEmpty: MessageBox MB_OK "$SMPROGRAMS\${company} isn't empty" EndOfCheckIfStartMenuIsEmpty: So what's wrong in my code? I want to check if $SMPROGRAMS\${company} is empty and if it is, that i want to delete it. Tnx in advance Kresimir |
|
|
|
|
|
#2 |
|
Major Dude
Join Date: Jun 2001
Posts: 1,173
|
|
|
|
|
|
|
#3 |
|
Junior Member
Join Date: Apr 2009
Posts: 25
|
Tnx. :-)
|
|
|
|
|
|
#4 |
|
Moderator
Join Date: Nov 2002
Location: Birmingham, England
Posts: 8,202
|
Just use RMDir without the /r switch to delete a folder only if it is empty.
Stu Need an installer? http://www.afrowsoft.co.uk |
|
|
|
|
|
#5 |
|
Junior Member
Join Date: Apr 2009
Posts: 25
|
i thought that RMDir /r means remove directory recursively. Are you sure that RMDir /r will remove only empty folder(s)?
|
|
|
|
|
|
#6 |
|
Major Dude
Join Date: Jun 2001
Posts: 1,173
|
no, he means -without- /r.
I.e. code: will only remove the "c:\temp" folder if it is empty. That's the default behavior, but it's not really appropriate for detecting whether it is or is not empty -before- an RMDir command (you'd have to check whether RMDir worked or not and if it did work.. depending on your code.. re-create it.. blurgh; hence that other function) |
|
|
|
![]() |
|
|||||||
| Thread Tools | Search this Thread |
| Display Modes | |
|
|