Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 '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 '14 at 12:45
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 '14 at 13:17

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.