Create a please wait window in VBscript
Posted on 2005-03-19
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.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
Set regex = New RegExp
'Get logged in users profile
userProfile = shell.ExpandEnvironmentStrings("%USERPROFILE%")
userName = shell.ExpandEnvironmentStrings("%USERNAME%")
'manipulate userProfile string to get the profile directory
strProfileDir = Left(userProfile, InStrRev(userProfile, "\"))
'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|administrator|all users|default user|localservice|networkservice|" & userName
.Ignorecase = True
.global = True
Set objProfileDir = fso.GetFolder(strProfileDir)
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
WScript.Echo "Completed deleting profiles"