bit of help needed .... Pretty Pwease
Back into a windows Enviroment after being in *Nix / Apple enviromentt for years ...
One of the problems we are having is the Network recyler folder is filling some 200 Servers up with space - Folder redirect is a mess and GPO cannot be touched - Else i would of just cleared this up ...
What im after is a VBSCRIPT i can just run against the Home drives of network user to erase all the recycler data in one go
\\servername\home\username\recycler << this folder gets blatted
Has any kind sir got a script that just does this - or can somebody point me in the right direction .... Pwetty Pwease ?
Save this VBScript snippet to Whatever.vbs. Create a text file with the name of each server per line, like:
Replace "C:\servers.txt" with the name of that text and run the script from a command prompt, like:Code:server1 server2 ....
Here's the code:Code:cscript /nologo Whatever.vbs
Let me know how it goes.Code:serverList = "C:\servers.txt" Set fso = CreateObject("Scripting.FileSystemObject") servers = Split(fso.OpenTextFile(serverList, 1, False).ReadAll, vbCrLf) For Each servername In servers homePath = "\\" & servername & "\home" WScript.StdOut.WriteLine "Checking '" & homePath & "'..." If fso.FolderExists(homePath) Then On Error Resume Next For Each userFolder In fso.GetFolder(homePath).SubFolders Err.Clear WScript.StdOut.Write vbTab & "Emptying '" & userFolder & "'..." fso.DeleteFile userFolder & "\*.*", True For Each subFolder In fso.GetFolder(userFolder).SubFolders fso.DeleteFolder subFolder, True Next If Err.Number = 0 Then WScript.StdOut.WriteLine "Success!" Else WScript.StdOut.WriteLine "Failed." End If Next On Error GoTo 0 End If Next
There are currently 1 users browsing this thread. (0 members and 1 guests)