Solved

Empty Recycle bin on exit using Group Policy

Posted on 2008-06-17
4
9,872 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

by Batuhan Cetin In this article I will be guiding through the process of removing a failed DC metadata from Active Directory (hereafter, AD) using the ntdsutil tool in a Windows Server 2003 environment. These steps are not necessary in a Win…
ADCs have gained traction within the last decade, largely due to increased demand for legacy load balancing appliances to handle more advanced application delivery requirements and improve application performance.
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

617 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