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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
Shanmuga SundaramDirector 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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Batch

From novice to tech pro — start learning today.