Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


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

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

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

Question has a verified solution.

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

Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
The SignAloud Glove is capable of translating American Sign Language signs into text and audio.
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 …
Starting up a Project

571 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