WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

System UDFs

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

UDF to Empty recycle bin

 Keywords: Empty recycle bin recyclebin  

udfEmptyRecycleBin:


#DefineFunction udfEmptyRecycleBin(driveroot)
	;Windows NT/2000: Requires Windows 2000 (or Windows NT 4.0 with Internet Explorer 4.0 or later). 
	;Windows 95/98/Me: Requires Windows 98 (or Windows 95 with Internet Explorer 4.0 or later). 
	;HRESULT SHEmptyRecycleBin(
	;    HWND hwnd, 
	;    LPCTSTR pszRootPath, 
	;    DWORD dwFlags);
	S_OK = 0
	SHERB_NOCONFIRMATION = 1 ; No dialog box confirming the deletion of the objects will be displayed.  
	SHERB_NOPROGRESSUI= 2 ; No dialog box indicating the progress will be displayed.  
	SHERB_NOSOUND=4 ; No sound will be played when the operation is complete. 
	dllHandle = DllLoad(strCat(DirWindows(1),"Shell32.dll"))
	if driveroot != ""
		ret = DllCall(dllHandle,long:"SHEmptyRecycleBinA",lpnull,lpstr:driveroot,long:SHERB_NOCONFIRMATION|SHERB_NOPROGRESSUI|SHERB_NOSOUND)
	else
		;Note: Inorder to empty recycle bins on all drives pass a blank string.
		ret = DllCall(dllHandle,long:"SHEmptyRecycleBinA",lpnull,lpnull,long:SHERB_NOCONFIRMATION|SHERB_NOPROGRESSUI|SHERB_NOSOUND)
	endif
	if ret == S_OK
	   return 1
	else
	   return 0
	endif
#EndFunction

;Empties recycle bin on c: drive
;Note: Inorder to empty recycle bins on all drives pass a blank string.
driveroot = "c:"
ret = udfEmptyRecycleBin(driveroot)
if ret
	   Message("Recycle bin","Emptied")
else
	   Message("Recycle bin","Not Emptied")
endif

Article ID:   W15312
File Created: 2003:02:20:13:55:20
Last Updated: 2003:02:20:13:55:20