Page 1 of 1
command line connect with friendly name possible?
Posted: Fri Oct 15, 2021 2:11 pm
by lopr
Hello,
openvpn connect switched from connecting to a profile via the profile name to an arbitrary ID (--connect-shortcut=12345678901234)
Now my autoconnect scripts dont work anymore.
Is there any possibility to still connect via the friendly name or is it possible to set the ID when importing the profile?
Re: command line connect with friendly name possible?
Posted: Fri Nov 05, 2021 10:13 am
by lopr
apparently not..
here is a small PS script to read out the ID and connect with it:
Code: Select all
$profilename="whateveryourprofilenamecontains"
$vpnhost="hostname or IP of the VPN server in your profile"
if (!(Test-Path Variable:\vpnid)) {
$json = & 'C:\Program Files\OpenVPN Connect\OpenVPNConnect.exe' --list-profiles | Out-String
$o = $json | ConvertFrom-Json
foreach ($vpnprofile in $o) {
if (($vpnprofile.name -match ".*$profilename.*") -and ($vpnprofile.host -eq "$vpnhost")) {
$vpnid=$vpnprofile.id
}
}
}
if (!(Test-Path Variable:\vpnid)) {
echo "no suitable vpnprofile found"
exit 1
}
Start-Process -NoNewWindow -FilePath "C:\Program Files\OpenVPN Connect\OpenVPNConnect.exe" -ArgumentList "--connect-shortcut=$vpnid" -Wait
Re: command line connect with friendly name possible?
Posted: Fri Nov 05, 2021 1:28 pm
by openvpn_inc
Hello lopr,
Not sure how you found that command line option, because it's not in our documentation on our site. But in any case, yeah, this is not optimal. I mean, it works fine internally in our app, and technically you can parse the output of the --list-profiles option and get the ID that way, but we could make this better. I think you can guess why friendly name isn't being used anymore - due to collision of similarly named profiles.
I've passed on this ticket to my colleagues that work on the OpenVPN Connect app, and they'll come up with some way to deal with this on the command line in a better way.
Kind regards,
Johan
Re: command line connect with friendly name possible?
Posted: Mon Nov 08, 2021 3:04 pm
by lopr
openvpn_inc wrote: ↑Fri Nov 05, 2021 1:28 pm
Not sure how you found that command line option, because it's not in our documentation on our site.
Hi Johan
you can create a connect shortcut on the desktop when viewing your profiles and read out the parameter from there (also the --disconnect-shortcut).
But when you're at it with your colleague maybe you could ask to implement more command line options

i would love to have a way to see if the client is connected and with which profile.