Skip to main content

Auto connect OpenVPN

· One min read

> Version 2.5

Ref: Configuring OpenVPN to run automatically on system startup

  • Put .ovpn config file in folder %ProgramFiles%\OpenVPN\config-auto\
  • Set OpenVPNService service to Automatic

Using PowerShell

Administrator PowerShell
$action = New-ScheduledTaskAction -Execute "`"${env:ProgramFiles}\OpenVPN\bin\openvpn.exe`"" -Argument "--config `"${env:UserProfile}\OpenVPN\config\OpenVPN.ovpn`""

$principal = New-ScheduledTaskPrincipal -UserId SYSTEM

$trigger = New-ScheduledTaskTrigger -AtLogOn

$task = New-ScheduledTask -Action $action -Principal $principal -Trigger $trigger

Register-ScheduledTask -TaskName OpenVPN -InputObject $task

Using GUI

Start Task Scheduler

Start Task Scheduler

Create Task

Create Task

Change User or Group to SYSTEM

Change User or Group to SYSTEM

TriggerNew

New Trigger

Begin the taskAt log on

At log on

ActionsNew

New Action

  • Set Program to "%ProgramFiles%\OpenVPN\bin\openvpn.exe"
  • Set Arg to --config "<OpenVPN.ovpn path>"

Action