Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

deleting script?

Status
Not open for further replies.

jsilveira

MIS
Feb 7, 2005
46
CA
Hi,

Does anyone know how to create a script that you can have it run when a user logs off? I would like the script to delete the contents of both Temp and Temporary Internet files.

Perhaps, there is a program that I could use?

Thx.
 
If you are running a Windows 2000 Domained based network you can do this with the startup/shutdown scripts in group policy.

Or you can run mmc, the add the group policy object editor, choose local computer and then add a shutdown script under Windows Settings - Scripts.
 
Hi,

I'm running windows xp, and started looking into running a batch file. However, it doesnt seem to be able to delete the contents of hidden files.. any suggestions?

thx
 
Certainly the Scheduled Task tool in Control panel would permit a logoff script to run.

The question of deleting certain files can be a permissions issue at times.
Rather than at logoff, try at logon for a limited user. Both states are supported for scripting by Scheduled Tasks and Group Policy.

By the way, using the "sageset" feature of the disk cleanup tool will simplify things:
 
IE/ Tools/ Internet Options/ Advanced/ (Settings) Security/ "Empty Temporary Internet Folder when Browser is closed"

Specifies whether to clear the Temporary Internet Files folder when you close the browser.


Scripting to clear the Temp folder, follow other posters excellent advise.

Disk Cleanup will not delete Temps files less than a week old without a Registry modification.
 
Your XP machine like any domain computer will support 4 different kinds of "events" for scripting. Startup, Shutdown, Logon, Logoff.

Startup and Shutdown apply to the computer and will take place before and after a user logs in. Login and Logoff apply to users and take place while the user logon/logoff are being processed.

It is possible to delete hidden files using vbscript. Please post more details of what you are trying to do and I can help.

I hope you find this post helpful.

Regards,

Mark
 
Hi,

I want to create a batch file that when a user logs off, the temporary internet files and temp directories are deleted.
 
Code:
'==========================================================================
'
' NAME: EmptyTempAndIETempFolders.vbs
'
' AUTHOR: Mark D. MacLachlan , The Spider's Parlor
' URL: [URL unfurl="true"]http://www.thespidersparlor.com[/URL]
' DATE  : 4/9/2005
'
' COMMENT: Empty's user temp folder and IE Temp Internet Folders
'
'==========================================================================
Dim WSHShell
Dim colUsrEnvVars
Dim fso 
Dim oFolder
Dim oFile
Dim oSubFolder
Dim Path
Dim IEPath

Set WSHShell = CreateObject("WScript.Shell")
Set colUsrEnvVars = WSHShell.Environment("USER")
Set fso = CreateObject("Scripting.FileSystemObject")

Path = colUsrEnvVars("Temp")

'Comment out the following line if you want to keep 
'the Files directly in the Temp folder
KillFiles(Path)

Set oFolder = fso.GetFolder(Path)
Set colSubfolders = oFolder.Subfolders

For Each oSubfolder in colSubfolders
	KillFiles(oSubFolder)
	'Comment out the following line if you want to keep 
	'the subdirectories directories and just empty them
    fso.DeleteFolder(oSubFolder)
Next

IEPath = "HKCU\Software\Microsoft\Windows\"
WSHShell.RegWrite IEPath & "ShellNoRoam\MUICache\@inetcplc.dll,-4750","Empty Temporary Internet Files folder when browser is closed","REG_SZ"
WSHShell.RegWrite IEPath & "CurrentVersion\Internet Settings\Cache\Persistent","0","REG_DWORD"

Function KillFiles(TargetDir)

Set oFolder = fso.GetFolder(TargetDir)
	For Each oFile In oFolder.files
	   	oFile.Delete True
	Next
End Function

I hope you find this post helpful.

Regards,

Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top