Scheduled Tasks Run-As


hi all,

i need automate process of ensuring vpn connection active, or start 1 if it's not (via cisco's anyconnect). have vbscript start

net stop vpnagent

and

net start vpnagent

each of commands above contain a delay in between. start shell, start vpncli program, , set delay 15 seconds. pass "disconnect" shell, delay again, , try start vpn connection passing connect vpn_profile command. task runs ok when set run "administrators" group, confirm opening new cmd window , running vpncli state, , see state connected. however, i'm unable select option "run whether user logged on or not".

so, created new local admin user, 'newuser', , added user administrators group, however, task not seem execute successfully; when running vpncli state, show disconnected in cmd window.

what doing wrong here? below subroutine try run:

sub vpn_open
  vpn_profile = "vpn-1.myvpnhost.com"
  vpn_user = "vpnuser"
  ' if password contains special characters, enclose characters in curly braces {}.
  vpn_password = "vpnuserpassword"
 
  set wshshell = wscript.createobject("wscript.shell")
  wshshell.run "net stop vpnagent"
  wscript.sleep 15000
  wshshell.run "net start vpnagent"
  wscript.sleep 15000
  wshshell.run """%programfiles(x86)%\cisco\cisco anyconnect secure mobility client\vpncli.exe"""
  wshshell.appactivate "cisco anyconnect secure mobility client"
  wscript.sleep 15000
  wshshell.sendkeys "disconnect~"
  wscript.sleep 15000
  wshshell.sendkeys "connect " & vpn_profile & "~"
  wscript.sleep 60000
  wshshell.sendkeys vpn_user & "~"
  wscript.sleep 5000
  wshshell.sendkeys vpn_password & "~"
  wscript.sleep 30000
  wshshell.sendkeys "exit~"
end sub 'vpn_open

thanks.

hi,

>however, i'm unable select option "run whether user logged on or not".

so, created new local admin user, 'newuser', , added user administrators group, however, task not seem execute successfully; when running vpncli state, show disconnected in cmd window.

you need change in task's properties.and if  you don't select 'run highest permission',please select , test again.

since not programmer,i can't check script right or wrong,you post on msdn forum further assistant script.

https://social.msdn.microsoft.com/forums


best regards
cartman
please remember mark replies answers if help. if have feedback technet subscriber support, contact tnmff@microsoft.com




Windows Server  >  Security



Comments

Popular posts from this blog

server manager error: ADAM.events.xml could not be enumerated.

Cannot access Anywhere Access using domain name?

WMI Failure: Unable to update Local Resource Group