01-23-2017 09:07 AM
Hi all,
I have a scheduled task that will execute a VBS file. This script will execute vpncli in a command line window and send the login username/password to this window. However, the task doesn't seem to execute properly. I confirm this when, after executing the scheduled task, I open a new command line window and check that connection status executing vpncli. How can I resolve this? Thanks.
-Rudy.
01-23-2017 12:47 PM
Hi Rudy,
Can you share the VBS so we try to figure it out what is going wrong?
Hope this info helps!!
Rate if helps you!!
-JP-
01-23-2017 02:30 PM
Below is the function subroutine I call: (please pardon the sleep lengths)
Sub VPN_open
VPN_Profile = "vpn.myhost.com"
VPN_User = "USERNAME"
' If the password contains special characters, enclose the characters in curly braces {}.
VPN_Password = "PASSWORD"
oShell.Run "cmd"
WScript.Sleep 100
oShell.AppActivate "C:\Windows\System32\cmd.exe"
oShell.SendKeys "vpncli connect " & VPN_Profile & "~"
WScript.Sleep 30000
oShell.SendKeys VPN_User & "~"
WScript.Sleep 15000
oShell.SendKeys VPN_Password & "~"
WScript.Sleep 15000
oShell.SendKeys "exit~"
End Sub 'VPN_open
Thanks in advance.
01-24-2017 08:42 AM
Hi rmenjivar1,
I found a way to do it like this:
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run """%PROGRAMFILES(x86)%\Cisco\Cisco AnyConnect Secure Mobility Client\vpncli.exe"""
WshShell.AppActivate "Cisco AnyConnect Secure Mobility Client"
WScript.Sleep 3000
WshShell.SendKeys "connect " & VPN_Profile & "~"
WScript.Sleep 3000
WshShell.SendKeys VPN_User & "~"
WScript.Sleep 3000
WshShell.SendKeys VPN_Password & "~"
WScript.Sleep 3000
Hope this info helps!!
Rate if helps you!!
-JP-
01-24-2017 12:51 PM
In addition,
I'm currently trying to run some of the commands manually and come across the following output when attempting the connection "vpncli connect vpn.myvpnsite.com":
01-24-2017 09:10 AM
Thanks JP,
How should I go about making this a scheduled task? That's weird is that it seems to work whenever I execute my original code from the command line manually, but not when it's run as a scheduled task. I even select to run this task as "SYSTEM" with highest privilege.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide