S h o r t S t o r i e s

// Tales from software development

Archive for September 2014

Executing a command on Windows startup

leave a comment »

I keep overlooking the extended functionality of Windows Scheduled Tasks and here’s another example…

I want a particular Windows server to automatically connect to a VPN when the server starts. Not when someone logs on but when Windows starts.

The RASDial command can be used to connect to a VPN, e.g. rasdial “Head Office VPN”¬†username pa$$word

The problem is, how to execute this without a logged in user ?

The Schedule tab of the scheduled task properties dialog has options for At System Startup, At Logon, and When Idle, as well as the more commonly used Daily, Weekly, Monthly options:

scheduled_task_at_system_startup

Alternatively, a scheduled task that runs at Windows start up can be created using the SchTasks command line tool:

schtasks /create /tn “Start VPN” /ru SYSTEM /sc ONSTART /tr “rasdial \”Head Office VPN\”¬†username pa$$word”

 

Written by Sea Monkey

September 17, 2014 at 8:00 pm

Posted in Environments

Tagged with