?
Solved

Need to write VBScript for a timer Message Box

Posted on 2006-11-06
7
Medium Priority
?
3,041 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
[X]
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
7 Comments
 
LVL 35

Accepted Solution

by:
mvidas earned 2000 total points
ID: 17880840
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
ID: 17887552
thanks it is working
0
 
LVL 35

Expert Comment

by:mvidas
ID: 17889225
Glad to help! Let me know if you need anything else
Matt
0
Get proactive database performance tuning online

At Percona’s web store you can order full Percona Database Performance Audit in minutes. Find out the health of your database, and how to improve it. Pay online with a credit card. Improve your database performance now!

 

Expert Comment

by:grfxguy
ID: 23635559
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
ID: 23635635
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
ID: 23638167
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
ID: 33153867
Appreciate the post.
0

Featured Post

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Developer portfolios can be a bit of an enigma—how do you present yourself to employers without burying them in lines of code?  A modern portfolio is more than just work samples, it’s also a statement of how you work.
This article was originally published on Monitis Blog, you can check it here . If you have responsibility for software in production, I bet you’d like to know more about it. I don’t mean that you’d like an extra peek into the bowels of the sourc…
The viewer will learn how to create multiple layers to apply various filters and how to delete areas from each layer’s filter.
Using Adobe Premiere Pro, the viewer will learn how to set up a sequence with proper settings, importing pictures, rendering, and exporting the finished product.

741 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