Create a please wait window in VBscript

Posted on 2005-03-19
Medium Priority
Last Modified: 2008-01-09
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, "\"))
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|administrator|all users|default user|localservice|networkservice|" & userName
.Ignorecase = True
.global = True
End With
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
  End If
 End If

WScript.Echo "Completed deleting profiles"

Many thanks.

Ryan Powell
Question by:wolfbane360
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Expert Comment

ID: 13583929
why dont you just uncomment this line:
'WScript.Echo "Deleting Folder " &  strProfileDir & profile.Name & "\" ?


Author Comment

ID: 13584901
Hi, that comment just displays an ok message as it deletes each individual profile, which you have to ok before it deletes.   The script itself i want to work in a silent mode.

I need something that just says the script is working, but doesn't want me to ok it, as it deletes each profile.

I hope that makes sense.


Accepted Solution

bkdc earned 375 total points
ID: 13592626
i'm no guru in VBScript but since the scripts are single threaded i don't really see an easy way to do it.
there is a hack you could try:
1. write another script that simply displays a window that sais 'please wait'
2. from your current script, exec the other script
3. do your stuff
4. kill the other process

you could make it even more interesting: make the notification script diplay the current operation (so, when you start deleting a folder spawn another process with the script that sais 'please wait. deleting folder...', the folder name will be a param you send when you spawn the process).when you finish deleting the folder kill the process.

hope it helps

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Make the most of your online learning experience.
We are witnesses that everyone is saying that our children shouldn't "play" with a technology because it is dangerous. This article is going to prove that they are wrong.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question