Hi, I have a VBscript that deletes local profiles on my workstations. The thing is whilst the script is running you can't tell that it's working. Is there a way to display a window that says something like "please wait, deleting profiles" until the whole script is complete.
My VBscript is:
Set shell = CreateObject("WScript.Shel
l")
Set fso = CreateObject("Scripting.Fi
leSystemOb
ject")
Set regex = New RegExp
'Get logged in users profile
userProfile = shell.ExpandEnvironmentStr
ings("%USE
RPROFILE%"
)
userName = shell.ExpandEnvironmentStr
ings("%USE
RNAME%")
'manipulate userProfile string to get the profile directory
strProfileDir = Left(userProfile, InStrRev(userProfile, "\"))
With regex
'below is the regular expression pattern that is tested against the profile name\
'you will need to add the string of profiles you DO NOT WANT DELETED here followed
'by the pipe character "|". Hopefully this makes sense.
.pattern = "Admin*|sweepupd|administr
ator|all users|default user|localservice|networks
ervice|" & userName
.Ignorecase = True
.global = True
End With
Set objProfileDir = fso.GetFolder(strProfileDi
r)
Set colUserProfiles = objProfileDir.SubFolders
For Each profile In colUserProfiles
If Not regex.Test(profile.name) Then
if DateDiff("d", profile.DateLastModified, Now()) < 365 Then
'WScript.Echo "Deleting Folder " & strProfileDir & profile.Name & "\"
'uncomment the following line once you are certain of the folders you want deleted.
fso.DeleteFolder strProfileDir & profile.Name, TRUE
End If
End If
Next
WScript.Echo "Completed deleting profiles"
Many thanks.
Ryan Powell
Start Free Trial