Solved

Empty Recycle bin on exit using Group Policy

Posted on 2008-06-17
4
9,714 Views
Last Modified: 2011-12-14
Is it possible to empty a Users Recycle bin automatically when they log off using Group Policy?
0
Comment
Question by:RobWasho
  • 2
4 Comments
 
LVL 5

Expert Comment

by:AC_Nova
ID: 21801029
0
 

Author Comment

by:RobWasho
ID: 21801300
Thanks for the quick response.  When I run the script I get an error in Line1 Char:28 Error: Expected end of statement code:800A0401

Any ideas?

0
 
LVL 5

Accepted Solution

by:
AC_Nova earned 250 total points
ID: 21801367
Download the app, download version 4.71+ of Windows shell.dll.
Check the script for syntax errors.  I have used this before and had no issues.

Hope this helps
0
 
LVL 24

Assisted Solution

by:purplepomegranite
purplepomegranite earned 250 total points
ID: 21801490
This VBScript empties the recycle bin, and doesn't require any third party utilities.  Simply add it as a logoff script.
Option Explicit
 
Dim objWshShell, objFSO, objWshNetwork
Dim objRecycleBin, objFolderItems, objItem, strSpecialFolderName
 
'Setup main variables and objects
Set objWshShell = WScript.CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objWshNetwork = WScript.CreateObject("WScript.Network")
 
Set objRecycleBin = GetSpecialFolderObject("Recycle Bin")
Set objFolderItems = objRecycleBin.Items()
For Each objItem In objFolderItems
	If (objItem.Type = "File Folder") Then	
		objFSO.DeleteFolder(objItem.Path)
	Else
		objFSO.DeleteFile(objItem.Path)
	End If
Next
 
Function GetSpecialFolderObject(NameOfFolder)
	Dim objShellApp, i, objSpecialFolder
	Set objShellApp = CreateObject("Shell.Application")
	On Error Resume Next
	For i=0 To 40	'40 is highest value for special folders
		Set objSpecialFolder = objShellApp.NameSpace(i)	
		If (StrComp(objSpecialFolder.Title,NameOfFolder,vbTextCompare)=0) Then
			Set GetSpecialFolderObject = objSpecialFolder
			Exit For
		End If
	Next
	Err.Clear
End Function

Open in new window

0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

So you have two Windows Servers and you have a directory/folder/files on one that you'd like to mirror to the other?  You don't really want to deal with DFS or a 3rd party solution like Doubletake. You can use Robocopy from the Windows Server 200…
Organizations create, modify, and maintain huge amounts of data to help their businesses earn money and generally function.  Typically every network user within an organization has a bit of disk space to store in process items and personal files.   …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question