Solved

Need to write VBScript for a timer Message Box

Posted on 2006-11-06
7
3,027 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
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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 

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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Free employee timeclock 7 54
Choppy program performance on Windows Server 2012 20 86
PC freezes and shutdowns becoming more frequent 17 106
How to open a .vcf file 11 54
Let’s list some of the technologies that enable smooth teleworking. 
Healthcare organizations in the United States must adhere to the guidance of both the HIPAA (Health Insurance Portability and Accountability Act) and HITECH (Health Information Technology for Economic and Clinical Health Act) for securing and protec…
The viewer will learn how to set up a document for the web and print and the recommended PPI for printing.
The viewer will learn how to create multiple layers to apply various filters and how to delete areas from each layer’s filter.

863 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

20 Experts available now in Live!

Get 1:1 Help Now