Possible to have a batch file that....

Soldato
Joined
18 Oct 2002
Posts
10,080
Location
At home
Hi,

On our terminal servers we set a GP so when users log out it deleted the roaming profile. However some don't go for whatever reason.


Is it possible to write a batch file that maybe every night deletes all the stale profiles in C:\doc and settings.

Will have to leave the default ones there though. Can you do exclusions ?
 
This runs on shutdown, so normally once a day.

Code:
ON ERROR RESUME NEXT

ProfPath = "C:\Documents and Settings\"

Dim fso
Dim aFolder
Dim aSubFolder

Set fso = createobject("Scripting.FileSystemObject")

Set wshShell = CreateObject("WScript.Shell")
strUser = wshShell.ExpandEnvironmentStrings("%USERNAME%")

Set aFolder = fso.GetFolder(ProfPath)
Set bSubFolder = aFolder.Subfolders

For Each aSubFolder in bSubFolder
  Select Case lcase(aSubFolder.Name)
    Case "administrator", "all users", "default user", "localservice", "networkservice"
      'Ignore
    Case strUser
      'Ignore
    Case Else
      fso.DeleteFolder(ProfPath & aSubFolder.Name),True
  End Select
Next

as a batch file, how does that work ?? if a script umm how does that work ? :p
 
Back
Top Bottom