Take the 2-minute tour ×

I've created a batch file called restart.bat

:: Open a Telnet window
start telnet.exe
:: Run the script
%systemroot%\system32\cscript.exe //Nologo //B C:\Scripts_and_Tools\SendKeys.vbs

This is the vbs script

set OBJECT=WScript.CreateObject("WScript.Shell")
WScript.sleep 50
OBJECT.SendKeys "root{ENTER}"
WScript.sleep 50
OBJECT.SendKeys "password{ENTER}"
WScript.sleep 50
OBJECT.SendKeys "boot action=reset{ENTER}"
WScript.sleep 3000
WScript.sleep 50
WScript.sleep 50
OBJECT.SendKeys " exit{ENTER}"
WScript.sleep 50
OBJECT.SendKeys " "

Running it manually works fine, but running it as task scheduler it will show it has completed but it didn't work.

share|improve this question
Are you impersonating a user during the task run? I have a feeling it's failing to run under the SYSTEM account. –  Nathan C Jul 14 at 12:07
@NathanC I'm running it under a domain admin account. It shows the task is completed but I can see telnet.exe still running in process. –  lbanz Jul 14 at 12:45

1 Answer 1

up vote 2 down vote accepted

The task runs in user session 0 by default and does not interact with the desktop. See


You can confirm if this is your issue but running the Task Scheduler task manually while logged into the domain admin account it runs under. The telnet window, etc. should run at that point in the interactive desktop.

For this type of click/keys automation I recommend using Autoit as it can send the input directly to the proper window.

share|improve this answer
+1 - or Firedaemon works too with the existing script. –  TheCleaner Jul 14 at 13:17

Your Answer


