Question Locked

VBScript that will delete Cookies in a Users Profile

0 helpful
2 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I'm working on a simple script that will go through all of the user profiles located on a network share and delete the cookies located under their TSProfile Folder. Some of the user folders will not have TSProfiles while others do. Here is the script I've been trying to get to work:

Const DeleteReadOnly = TRUE

Set objFSO = CreateObject("Scripting.FileSystemObject")
set wshNetwork = Wscript.CreateObject("Wscript.Network")
struser = wshNetwork.UserName
objFSO.DeleteFile ("E:\" & struser & "tsprofile\Cookies\*.txt"), DeleteReadOnly

I get a script host error with the following:

Line 6
Char 1
Error: File not found
Code: 800A0035

Any help would be appreciated

2 replies

by ic-it

on the root of the E drive?
Here is one I sometimes deploy to clean up profiles on logoff. It is only set for Internet Explorer Cache and Temp files.
It could do Cookies with the addition of this line;
fso.DeleteFolder "C:\Documents and Settings\" & WshNetwork.UserName & "\Temp"

on error resume next
dim wshshell, WshNetwork, fso
Set WshShell = WScript.CreateObject("WScript.Shell")
Set WshNetwork = WScript.CreateObject("WScript.Network")
Set Fso = CreateObject("Scripting.FileSystemObject")

fso.DeleteFolder "C:\Documents and Settings\" & WshNetwork.UserName & "\Local Settings\Temp"
fso.CreateFolder "C:\Documents and Settings\" & WshNetwork.UserName & "\Local Settings\Temp"
fso.DeleteFolder "C:\Documents and Settings\" & WshNetwork.UserName & "\Local Settings\Temporary Internet Files"
fso.CreateFolder "C:\Documents and Settings\" & WshNetwork.UserName & "\Local Settings\Temporary Internet Files"

This discussion is closed to new replies.