Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBScript - Pause till operation complete...

Status
Not open for further replies.

LukeT1

IS-IT--Management
Apr 21, 2010
9
GB
Hi,

This is my first VBScript, so I may need a little walking through here.

Basically, I have a script to kill all running VPN's, then open a certain VPN client and input username and password, connect to the VPN, edit a text file and open an EXE that uses TCP/IP.

The problem I am having is that when opening the VPN client (specifically Sonicwall) I can't seem to time it right to input username and password, and if I do time it right on my machine, it doesn't work on someone else's slower machine.

I need to edit my script to wait till Sonicwall has finished opening, press CTRL+B (connect) and then input the username and password.

This is currently the script I am using:


Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run """C:\Program Files\SonicWALL\SonicWALL Global VPN Client\SWGVpnClient.exe""",0,true
Dim oShell
Set oShell = WScript.CreateObject ("WScript.Shell")
wscript.Sleep 5000
oshell.sendkent "^b"
oshell.sendkeys "U"
oshell.sendkeys "S"
oshell.sendkeys "R"
oshell.sendkeys "N"
oshell.sendkeys "M"
oshell.sendkeys "E"
oshell.sendkeys "{Tab}"
oshell.sendkeys "P"
oshell.sendkeys "A"
oshell.sendkeys "S"


Help is much appriciated.

Cheers
 
Use WSHShell.Exec instead of WSHShell.Run.

With .Exec you can wait for execution to finish.


Here is a simple example. It will launch Calculator and will wait until you close it.
Code:
Dim WshShell, oExec
Set WshShell = CreateObject("WScript.Shell")

Set oExec = WshShell.Exec("calc")

Do While oExec.Status = 0
     WScript.Sleep 100
Loop

WScript.Echo oExec.Status

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Hi Mark,

Thanks for the reply.

I've tried your method, although I am still getting some issues.

With the Exec command, I have to wait for the program to finish. Though I need to keep running as it is a VPN connection.

Do you know a way in which I can pause the operation till the program has finished running (or even a way to put an echo box up until the program has finished loading, then continue on click?)

Thanks again,

Luke
 
I guess I don't understand what your issue is. I do notice that in your script you don't use AppActivate. You should always use that when using sendKeys to set the focus to your program you want to send input to.

Can you give me a better understanding of what you are trying to do? If you just want a message to pop up then you would use:

MsgBox("Please wait while VPN software is installed")

Script execution is linear. That message will prevent the script from continuing until the click OK.

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Basically I need the VPN software to enable a connection before it types the Username and Password.

I tried the AppActivate and it works a treat on my machine. I will try it on the slower machines.

Thanks Mark!

Much appricated!
 
Basically I need the VPN software to enable a connection before it types the Username and Password.

I tried the AppActivate and it works a treat on my machine. I will try it on the slower machines.

Thanks Mark!

Much appricated!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top