Most software packages written for Windows have an uninstall facility. However, there is no easy way to delete files that may already be open. The purpose of WipeDir is to facilitate the development of uninstall methods for small applications by allowing directories containing open files to be deleted as cleanly as possible.
The typical problem when uninstalling an application called GeeWhizz is that because the uninstall program itself is open (\program files\GeeWhizz\uninst.exe) it prevents the directory from being deleted. In this instance, provided the file wipedir.exe is located in the GeeWhizz directory, removal of the directory is achieved by the command wipedir /self. WipeDir waits up to five seconds for files to close - if still unable to delete the directory, it causes the directory to be deleted when Windows is restarted.
The WipeDir package includes two programs being wipedir.exe and wipedirC.exe. The first is a standard GUI Windows program. The second as a console version for use in batch files. Both versions must be called with command-line parameters - the user is not prompted for a directory to delete.
wipedir FullDirName [switches] |
or, for console use |
wipedirC FullDirName [switches] |
/Self |
- used as an alternative to a directory name. |
/NoConfirm |
- requires no user interaction. |
/NoRestart |
- fail if unable to delete dir without restarting Windows. |
/ShowProgress |
- display a Windows progress dialog (GUI version only). |
/SecurityCheck=off |
- do not check existence of file wipedir.ini |
Before attempting to delete a directory, the existence of the file wipedir.ini is checked.
If this file does not exist :-
This feature is intended to prevent accidental deletion of files during development and testing.
Keep the file wipedir.ini in an otherwise empty directory. Include it when building
an installation package. This should ensure accidental deletion of files is prevented but sensible
backup protocols are always advisable. Also see switches.
WipeDir attempts to delete the required directory using the Windows API function SHFileOperation.
When the /self switch is used :-
A command is saved in the Windows Registry. The command is run automatically (and deleted) when Windows is next restarted. The table below lists the registry key and the required command.
Key | HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnce |
Win NT/2000/XP | cmd.exe /C RD /S /Q DirName |
Win 95/98/ME | COMMAND.COM /C DELTREE.EXE /Y DirName |
Examples |
wipedir %Temp%\GeeWhizzInstaller /noconfirm wipedirC -norestart -noconfirm "C:\Program Files\GeeWhizz" "C:\Program Files\GeeWhizz\wipedir" /self /showprogress
CreateProcess- you MUST close the returned thread and process handles. ShellExecute- recommended ShellExecuteEx- DO NOT specify the flag SEE_MASK_NOCLOSEPROCESS.