+ Post New Thread
Results 1 to 2 of 2
Scripts Thread, Recyle Bin script in Coding and Web Development; Hi I am trying to write a script to empty users Bins at logoff. I must confess my scriping knowledge ...
  1. #1
    networkingNut's Avatar
    Join Date
    Oct 2008
    Location
    Midlands
    Posts
    144
    Thank Post
    15
    Thanked 2 Times in 2 Posts
    Rep Power
    13

    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

  2. #2
    networkingNut's Avatar
    Join Date
    Oct 2008
    Location
    Midlands
    Posts
    144
    Thank Post
    15
    Thanked 2 Times in 2 Posts
    Rep Power
    13

    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



SHARE:
+ Post New Thread

Similar Threads

  1. Empty recycle bin after n days
    By elsiegee40 in forum Scripts
    Replies: 11
    Last Post: 25th June 2010, 09:58 AM
  2. [Pics] Send Recycle Bin To Recycle Bin?
    By DaveP in forum Jokes/Interweb Things
    Replies: 1
    Last Post: 7th September 2009, 11:29 PM
  3. Recycle bin
    By chrbb in forum Windows
    Replies: 15
    Last Post: 28th April 2008, 08:41 PM
  4. cgi-bin location
    By dezt in forum Web Development
    Replies: 7
    Last Post: 13th October 2007, 11:10 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •