我想到了。我使用了上面 Richard 指出的任务计划程序。
我将触发器设置为.. On an Event -> System -> Kernel-Power -> 42
如果有人有兴趣...这里是脚本(我是 PowerShell 脚本的初学者,所以欢迎您的输入)
$strComputerName = gc env:computername
$strVPN = 'c:\Program Files (x86)\Cisco Systems\VPN Client\vpnclient.exe'
$vpnArgs = 'connect', 'ProfileName', 'user', 'XXXXXXXX', 'pwd', 'XXXXXXXXXX'
[int]$count = 6
Write-Host "Checking for Internet Connectivity"
While (!([Activator]::CreateInstance([Type]::GetTypeFromCLSID([Guid]'{DCB00C01-570F-4A9B-8D69-199FDBA5723B}')).IsConnectedToInternet))
{
Write-Host "Sleeping for 10 seconds before checking for internet again"
Start-Sleep -s 10
$count--
if ( $count -eq 0)
{
Write-Host "Breaking from loop"
break
}
}
if ( $count -ne 0) { Invoke-Command -ScriptBlock { & $strVPN $vpnArgs } }
else { Write-Host "No Internet Connectivity, so not attempting VPN connection" }