Solved

Script to open VPN Anyconnect and Send Keys to it

Posted on 2015-02-23
1
189 Views
Last Modified: 2015-07-08
Hi All,

I'm using Visual Studio to create an SSIS package with a script task using script language Microsoft Visual Basic 2012 to open the vpncli.exe and connect to a server "000.00.00.000" with username "TestName" and password "TestPassword"

I'm having difficulties in sending keystrokes to the app, the app looks like dos. For example the steps that I put in is as follows:
Open vpncli.exe
>connect "000.00.00.000"
{enter}
"TestName"
{enter}
"TestPassword"
{enter}

I need this script to automate my login.

Regards
0
Comment
Question by:cErasmus
[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
1 Comment
 
LVL 70

Accepted Solution

by:
Qlemo earned 500 total points
ID: 40638275
What i use with PowerShell is this (works for x86 machines this way):
Add-Type -Assembly System.Windows.Forms

Push-Location 'C:\Programme\Cisco\Cisco AnyConnect Secure Mobility Client'

Start-Service vpnagent | Out-Null
Start-Process 'vpncli.exe' -Argumentlist 'connect 000.000.000.000'
sleep 3
'', 'TestName', 'TestPassword' | % {
  sleep -m 100
  [Windows.Forms.SendKeys]::SendWait("$_{ENTER}") 
}

Open in new window

0

Featured Post

Is your NGFW recommended by NSS Labs?

Ours is! NSS Labs Next Generation Firewall Test gives the WatchGuard Firebox M4600 a "Recommended" rating! Curious where your NGFW landed on the  Security Value Map? See the map and download the full report today!

Question has a verified solution.

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

Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
After creating this article (http://www.experts-exchange.com/articles/23699/Setup-Mikrotik-routers-with-OSPF.html), I decided to make a video (no audio) to show you how to configure the routers and run some trace routes and pings between the 7 sites…
After creating this article (http://www.experts-exchange.com/articles/23699/Setup-Mikrotik-routers-with-OSPF.html), I decided to make a video (no audio) to show you how to configure the routers and run some trace routes and pings between the 7 sites…

726 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