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

Script to Delete a File PLEASE HELP!

Status
Not open for further replies.

BryanErskine

IS-IT--Management
Dec 18, 2013
2
US
Ok Here is the problem, Our network the students log into google chrome and even when they log out the next user that logs in gets that students google chrome settings etc. In order to fix this I found a folder that can be deleted in order to fix this I want to have this script run at log off through the group policy however I am having an issue with the Script.
When I use this script I get a permissions Error at Line 10
Is there way to make this run as an administrator? The file is a hidden file.

I want the C:\Users\*\AppData\Local\Google\Chrome\User Data File deleted
I've tested just going in through windows explorer and deleting this file when I log off and on as another user the chrome data is all gone so this works, the script however ..... does not

I'm sure this is a very crude way of doing this however I am still new to scripting. Any help would be much appreciated.

Dim FSfolder
Dim subfolder
Dim i

set objshell = CreateObject("Wscript.shell")
Set FSO = CreateObject("Scripting.FileSystemObject")
Profile = strSysDrive & "C:\Documents and Settings"
Set FSfolder = FSO.GetFolder(Profile) 'getting the user profile folders

For Each subfolder In FSfolder.SubFolders

If (subfolder.Name <> "All Users" And subfolder.Name <> "Default User"_
and subfolder.Name <> "LocalService" and subfolder.Name <> "NetworkService") Then

folder1=Profile & "\" & subfolder.Name & "\Appdata\Local\Google\Chrome\User Data"

DeleteThisFolder(folder1)

end if

Next

'*******************************************************************************************************

Function DeleteThisFolder(FolderName)

If FSO.FolderExists(FolderName) Then
objshell.Run "CMD.EXE /C RD /S /Q """ & FolderName & """",0,True
End If

End Function

Please help and thank you for any help you can give.

Bryan
 
Why not simply this ?
Set objshell = CreateObject("WScript.Shell")
objshell.Run "CMD.EXE /C RD /S /Q ""%USERPROFILE%\Appdata\Local\Google\Chrome\User Data"""

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top