Solved

Empty Recycle bin on exit using Group Policy

Posted on 2008-06-17
4
9,583 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Preface Having the need * to contact many different companies with different infrastructures * do remote maintenance in their network required us to implement a more flexible routing solution. As RAS, PPTP, L2TP and VPN Client connections are no…
Many of us need to configure DHCP server(s) in their environment. We can do that simply via DHCP console on server or using MMC snap-in on each computer with Administrative Tools installed in a network. But what if we have to configure many DHCP ser…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

770 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