Solved

Need to write VBScript for a timer Message Box

Posted on 2006-11-06
7
3,025 Views
Last Modified: 2010-07-07
Hi Everyone...
I am in the middle of writing a Startup VBScript, inside this script there is an "if condition statement"...
When the “if statement” is true a message box should be appeared and closed automatically.
The question is:
How can I make an auto close message box that will be closed after 15 seconds?
Thanks a lot....

0
Comment
Question by:alkhaleej
7 Comments
 
LVL 35

Accepted Solution

by:
mvidas earned 500 total points
Comment Utility
Hi alkhaleej,

The wscript shell object has a .Popup method which closes after a specified amount of time.  An example for 15 seconds:

 Dim Wshell
 Set Wshell = CreateObject("wscript.shell")
 Wshell.Popup "Timed popup!", 15, "Popup title"
 Set Wshell = Nothing

After the Title argument there is also a Type argument, like msgbox, in case you want to ask the user about a yes/no/abort/ignore/etc, which can also return if the user actually clicked something or let the popup time out.  Check out the Popup method on msdn for more info (or just ask).

Matt
0
 

Author Comment

by:alkhaleej
Comment Utility
thanks it is working
0
 
LVL 35

Expert Comment

by:mvidas
Comment Utility
Glad to help! Let me know if you need anything else
Matt
0
Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 

Expert Comment

by:grfxguy
Comment Utility
Simple, elegant, and it works like a charm. Once again EE comes to the rescue.

Now, to make it absolutely perfect for my needs, is there a way to get the popup to display the drive letter string values that were entered earlier in the script?

Option Explicit
Dim objNetwork, strRemotePath1, strRemotePath2, strRemotePath3, strRemotePath4
Dim strDriveLetter1, strDriveLetter2, strDriveLetter3, strDriveLetter4

strDriveLetter1 = "S:"
strDriveLetter2 = "T:"
strDriveLetter3 = "U:"
strDriveLetter4 = "V:"

strRemotePath1 = "\\CFOTech-FS1\Data\QuickBooks"
strRemotePath2 = "\\CFOTech-FS1\Data\Miscellaneous"
strRemotePath3 = "\\CFOTech-FS1\Data\Pensoft"
strRemotePath4 = "\\CFOTech-FS1\Data\Lacerte"

Set objNetwork = CreateObject("WScript.Network")

' Section which maps four drives, S:, T:, U:, and V:
objNetwork.MapNetworkDrive strDriveLetter1, strRemotePath1
objNetwork.MapNetworkDrive strDriveLetter2, strRemotePath2
objNetwork.MapNetworkDrive strDriveLetter3, strRemotePath3
objNetwork.MapNetworkDrive strDriveLetter4, strRemotePath4


' Extra code to add a message box
Dim Wshell
Set Wshell = CreateObject("WScript.shell")
' Wshell.Popup "Mapped drives ""strDriveLetter1", "strDriveLetter2", "strDriveLetter3" & "strDriveLetter4"",7, "Drives mapped"
Wshell.Popup "Mapped drives S:, T:, U:, & V:.",7, "Drives mapped"
Set Wshell = Nothing

Wscript.Quit

If I use the first Wshell.Popup line, I get an error "Expecting conclusion". I have tried numerous combinations and placements of the quote marks, but it just moves the error to a different character on the same line. What am I doing wrong?

Thanks
Nick
0
 
LVL 35

Expert Comment

by:mvidas
Comment Utility
Hi Nick,

Generally, you should open a new question by clicking the "ask a related question" link near the comment box.  However, I'm happy to answer this here right now as I only have a minute and this should only take a minute.

What you'll want to use is:

Wshell.Popup "Mapped drives " & strDriveLetter1 & ", " & strDriveLetter2 & ", " & strDriveLetter3 & " & " & strDriveLetter4 & ".", 7, "Drives mapped"

You just had to add the & symbol to concatenate strings together (to put the comma after the drive letters).

Cheers
0
 

Expert Comment

by:grfxguy
Comment Utility
Thanks so much for you very prompt answer. I had tried something similar, but didn't quite have the syntax right. Your line worked perfectly.
0
 
LVL 1

Expert Comment

by:xEr72
Comment Utility
Appreciate the post.
0

Featured Post

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

Suggested Solutions

Article by: Rob
Notes 8.5 Archiving Steps and Tips This article covers setting up a Notes archive, and helps understand some of the menu choices making setting up and maintaining a Notes archive file easier.
The article will include the best Data Recovery Tools along with their Features, Capabilities, and their Download Links. Hope you’ll enjoy it and will choose the one as required by you.
Viewers will learn how to use the Hootsuite Dashboard.
XMind Plus helps organize all details/aspects of any project from large to small in an orderly and concise manner. If you are working on a complex project, use this micro tutorial to show you how to make a basic flow chart. The software is free when…

771 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now