Skip to content

Instantly share code, notes, and snippets.

@paveleremin
Created February 24, 2017 06:45
Show Gist options
  • Save paveleremin/323cf97e97990278d5ae321573c55f71 to your computer and use it in GitHub Desktop.
Save paveleremin/323cf97e97990278d5ae321573c55f71 to your computer and use it in GitHub Desktop.
Cisco AnyConnect: save password
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run """%PROGRAMFILES(x86)%\Cisco\Cisco AnyConnect Secure Mobility Client\vpnui.exe"""
WScript.Sleep 1500
WshShell.AppActivate "Cisco AnyConnect Secure Mobility Client"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{ENTER}"
WScript.Sleep 3500
WshShell.SendKeys "YourPassword"
WshShell.SendKeys "{ENTER}"
@odiszapc
Copy link

Works like a charm, I ended up with this:
(Change host and password with yours)

Set WshShell = WScript.CreateObject("WScript.Shell")

WshShell.Run """%PROGRAMFILES(x86)%\Cisco\Cisco AnyConnect Secure Mobility Client\vpnui.exe"""

WScript.Sleep 1500

WshShell.AppActivate "Cisco AnyConnect Secure Mobility Client"

WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "vpn.securehost.com"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{TAB}"
WshShell.SendKeys "{ENTER}"

WScript.Sleep 3500

WshShell.SendKeys "Password!$!#@"
WshShell.SendKeys "{ENTER}"


@VVVi
Copy link

VVVi commented May 20, 2020

Cool! If you use special symbols in pass then enclose it by braces {}, for example {~} https://devguru.com/content/technologies/wsh/wshshell-sendkeys.html

@paveleremin
Copy link
Author

@p333ter
Copy link

p333ter commented Feb 4, 2021

Good Job Pavel! It works for me too.

@arl-35890
Copy link

Hi, thanks Pavel for sharing this script.
I'm very unfamiliar with vbs, and I'm not sure to understand how this script is triggered? Do we have to create a schedule task to run this script as the startup of the machine?
Any help to understand how this works would be appreciated.
Thanks Guys

@JBerls
Copy link

JBerls commented Oct 29, 2021

Brilliant! Thanks so much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment