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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Deleting Cookies in multiple user folders

Status
Not open for further replies.
Jun 1, 2004
65
US
I'm trying to write a script that will go through all of my user TSProfiles and delete all of the files in the Cookies folder. The scripts I've found so far will transverse the %username% folders but errors out or does not run properly when I run it.

thanks
 
Perhaps you should show us what you are running and explain specifically how it fails.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Sub DeleteFileExtensions(strWildcards, strDirectory)
'Turn off error handling
On Error Resume Next

'Create an instance of the FileSystemObject
Dim objFSO
Set objFSO = Wscript.CreateObject("Scripting.FilesystemObject")
set wshNetwork = Wscript.CreateObject("Wscript.Network")
struser = wshNetwork.UserName
objFSO.DeleteFile "E:\" & struser & "tsprofile\Cookies\*.*",TRUE
End Sub
 
Ok, you gave us half of what I asked for. Also, what specific error are you trying to avoid with On Error Resume Next?

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
I'm not seeing any errors nor does it report it's failing, what I get is the script will run but does not clear out the cookies folder under the TSProfile folder in the users profile.
 
Hence my question regarding the use of On Error Resume next. Do you know why you put that particular line of code in there? Do you know what it does? Remove it and you will see errors (Assuming you don't have it elsewhere in your script). Then you can start to troubleshoot your code.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
With out the Continue on error I'm getting
Error: File not found
Code: 800A0035

The error referance the following VBScript Line:
objFSO.DeleteFile ("E:\" & struser & "tsprofile\Cookies\*.txt"), DeleteReadOnly

Again I need to go through multiple user profile directories on a network share and delete the cookies under the TSProfile folder.
 
sorry for butting in here ebgreen
steelcoyot
this is what you have posted, run it and see what your path is
Code:
 Dim objFSO
Set objFSO = Wscript.CreateObject("Scripting.FilesystemObject")
set wshNetwork = Wscript.CreateObject("Wscript.Network")
struser = wshNetwork.UserName
wscript.echo "E:\" & struser & "tsprofile\Cookies\*.*",TRUE
 
If you do this:

Remove the parens:

objFSO.DeleteFile "E:\" & struser & "tsprofile\Cookies\*.txt", DeleteReadOnly

Also, what is DeleteReadOnly? That is not the same as what you originally posted. Which post is correct?

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
GrimR thanks for the post, when I run the script you gave me and I get that the file runs correclty against my acount but I need it to go through all of the user folders on the server share. Do you know what VBScript command I could use for this?

Thanks
 
Well as long as you have adequate rights, and all the user folders are off the root of E:, then try this:

For Each oFolder in oFSO.GetFolder("E:\").SubFolders
objFSO.DeleteFile oFolder.Path & "\Cookies\*.txt", DeleteReadOnly
Next

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
EBGreen I get the following Script host error
Line: 2
Char: 1
Error: Object Required: "
Code: 800A01A8
 
Show the code that generates that error please.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Dim oFSO, oFolder
For Each oFolder in oFSO.GetFolder("E:\").SubFolders
objFSO.DeleteFile oFolder.Path & "\Cookies\*.txt", DeleteReadOnly
Next

Again I'm not a script writer nor do I know that much about VBScript
 
So it looks nlike you aren't creating the FileSystemObject object any more so try this:

Dim oFSO, oFolder
[red]Set oFSO = CreateObject("Scripting.FileSystemObject")[/red]
For Each oFolder in oFSO.GetFolder("E:\").SubFolders
[red]o[/red]FSO.DeleteFile oFolder.Path & "\Cookies\*.txt", DeleteReadOnly
Next


[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Echo the path that you are trying to delete on and makesure that it makes sense.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top