-
Recyle Bin script
Hi I am trying to write a script to empty users Bins at logoff. I must confess my scriping knowledge is pretty much non existant so I have been cytting bits from other scripts which we have :(
What I have got so ar is
Code:
'Script to Empty the recycle Bin on Logoff.
'Get User DN
Set objSysInfo = CreateObject("ADSystemInfo")
strUser = objSysInfo.UserName
If InStr(strUser, "Staff") Then
DEL \\rhs-svr-001\staff$\%username%\RECYCLER\*.*
End If
If InStr(strUser, "Year02") Then
DEL \\rhs-svr-001\year02$\%username%\RECYCLER\*.*
End If
If InStr(strUser, "Year03") Then
DEL \\rhs-svr-001\year02$\%username%\RECYCLER\*.*
End If
If InStr(strUser, "Year04") Then
DEL \\rhs-svr-003\year02$\%username%\RECYCLER\*.*
End If
If InStr(strUser, "Year05") Then
DEL \\rhs-svr-003\year02$\%username%\RECYCLER\*.*
End If
If InStr(strUser, "Year06") Then
DEL \\rhs-svr-001\year02$\%username%\RECYCLER\*.*
End If
If InStr(strUser, "Year07") Then
DEL \\rhs-svr-001\year02$\%username%\RECYCLER\*.*
End If
If InStr(strUser, "Year08") Then
DEL \\rhs-svr-003\year02$\%username%\RECYCLER\*.*
End If
If InStr(strUser, "Year09") Then
DEL \\rhs-svr-001\year02$\%username%\RECYCLER\*.*
End If
'Terminate script and engine
WScript.Quit
I have saved it as a bat but it does not seem to work. I would prefer to ue Vbscript. Howver when saved as a VB script it errors.
Any help is apreciated
nN
-
Update 8.3.2010
Update 8.3.2010
I have found the following script (Source: Empty Recycle Bin Script - Script Center - Spiceworks Community)
Code:
'#==============================================================================
'#==============================================================================
'# SCRIPT.........: emptyRecycleBin.vbs
'# AUTHOR.........: Joe Glessner
'# EMAIL..........: jglessner@gmail.com
'# VERSION........: 1.0
'# DATE...........: 02OCT09
'# COPYRIGHT......: 2009, laoae.com
'# LICENSE........: Freeware
'# REQUIREMENTS...:
'#
'# DESCRIPTION....: Empties the Recycle Bin on the local computer.
'#
'# NOTES..........: This has only been tested on Windows 7, though it should
'# work on all Windows versions, 2000 or later.
'#
'# This script will empty the Recycle bin, but will not
'# change the icon to show it has been emptied, until the
'# recycle bin has been opened by a user.
'#
'# CUSTOMIZE......:
'#==============================================================================
'# REVISED BY.....:
'# EMAIL..........:
'# REVISION DATE..:
'# REVISION NOTES.:
'#
'#==============================================================================
'#==============================================================================
'**Start Encode**
'#==============================================================================
'# START OF SCRIPT
'#==============================================================================
'Option Explicit
'On Error Resume Next
'#--------------------------------------------------------------------------
'# Declare Constants
'#--------------------------------------------------------------------------
Const RECYCLE_BIN = &Ha&
Const FILE_SIZE = 3
'#--------------------------------------------------------------------------
'# Declare Variables
'#--------------------------------------------------------------------------
Dim objShell, objFolder, objFSO, colItems
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(RECYCLE_BIN)
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set colItems = objFolder.Items
'#--------------------------------------------------------------------------
'# Delete everything in the Recycle Bin
'#--------------------------------------------------------------------------
For Each objItem in colItems
If (objItem.Type = "File folder") Then
objFSO.DeleteFolder(objItem.Path)
Else
objFSO.DeleteFile(objItem.Path)
End If
Next
'#==============================================================================
'# SUBROUTINES/FUNCTIONS/CLASSES
'#==============================================================================
'#==============================================================================
'# END OF FILE
'#==============================================================================
Whiel the for statement is running I would like to display a box the the student saying "Emptying your recycle bin". I dont want the box to have any buttons but just be timed so once the for statement has executed the box closes.
I ahve tried both MsgBox and document.writeln but document.writeln errors and MsgBox has buttons.
Sorry for such as newbe question but I am stumped
nN