command line connect with friendly name possible?

Official client software for OpenVPN Access Server and OpenVPN Cloud.
Post Reply
lopr
OpenVpn Newbie
Posts: 4
Joined: Fri Oct 15, 2021 2:01 pm

command line connect with friendly name possible?

Post by lopr » Fri Oct 15, 2021 2:11 pm

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?

lopr
OpenVpn Newbie
Posts: 4
Joined: Fri Oct 15, 2021 2:01 pm

Re: command line connect with friendly name possible?

Post by lopr » Fri Nov 05, 2021 10:13 am

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

User avatar
openvpn_inc
OpenVPN Inc.
Posts: 363
Joined: Tue Feb 16, 2021 10:41 am

Re: command line connect with friendly name possible?

Post by openvpn_inc » Fri Nov 05, 2021 1:28 pm

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
Image OpenVPN Inc.
Answers provided by OpenVPN Inc. staff members here are provided on a voluntary best-effort basis, and no rights can be claimed on the basis of answers posted in this public forum. If you wish to get official support from OpenVPN Inc. please use the official support ticket system: https://openvpn.net/support

lopr
OpenVpn Newbie
Posts: 4
Joined: Fri Oct 15, 2021 2:01 pm

Re: command line connect with friendly name possible?

Post by lopr » Mon Nov 08, 2021 3:04 pm

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.

Post Reply