Write a Logoff Script

I wish to write a logoff script that will delete the internet webpage history and clear the contents of a temporary mapped storage drive and desktop.

Any Ideas?

Thanks
LVL 2
andrewjones1987Asked:
Who is Participating?
 
Shanmuga SundaramConnect With a Mentor Director of Software EngineeringCommented:
This script will delete all the temporary files. Please check
dim foldername
Dim ofso
    Dim sDirectoryPath
    Dim oFolder
    Dim oFileCollection
    Dim ofoldercollection
    Dim oFile
    dim wshshell
dim WshSysEnv
    Set ofso = CreateObject("Scripting.FileSystemObject")
    Set WshShell = WScript.CreateObject("WScript.Shell")
On Error Resume Next
 
cleanfolder (ofso.GetSpecialFolder(2))
cleanfolder  (WshShell.ExpandEnvironmentStrings("%UserProfile%") & "\cookies\")
cleanfolder  (WshShell.ExpandEnvironmentStrings("%UserProfile%")& "\Local Settings\Temporary Internet Files\")
cleanfolder  (WshShell.ExpandEnvironmentStrings("%UserProfile%")& "\Local Settings\History\")
cleanfolder  (WshShell.ExpandEnvironmentStrings("%UserProfile%")& "\Recent")
wscipt.Quit 
 
Private Sub cleanfolder(foldername)
msgbox foldername
    Set ofso = CreateObject("Scripting.FileSystemObject")
 
    Set oFolder = ofso.GetFolder(foldername)
    
    Set ofoldercollection = oFolder.SubFolders
    For Each oFolder In ofoldercollection
    oFolder.Delete
    Next
    'This is used to get the temp directory. to point to another directory use as set ofolder = ofso.getfolder("C:\your path")
    Set oFolder = ofso.GetFolder(foldername)
    Set oFileCollection = oFolder.Files
 
    For Each oFile In oFileCollection
    Debug.Print oFile.Name
    oFile.Delete (True)
    Next
    Set ofso = Nothing
    Set oFolder = Nothing
    Set oFileCollection = Nothing
    Set oFile = Nothing
end sub

Open in new window

0
 
dlan75Commented:
Hi,
Will you batch be run from a server (domain controler) or directly from the computer?
0
 
andrewjones1987Author Commented:
be run from the workstation during logoff.
0
 
dlan75Commented:
Hi,
You can make much simpler than a vbscript by using some dos commands !
Look here for some help on dos, batch, ... http://www.computerhope.com/msdos.htm
Look here for all the dos commands : http://www.computerhope.com/msdos.htm#02
0
All Courses

From novice to tech pro — start learning today.