2
votes

I am trying to automate logging in to a bunch of RDP clients on a 2008 R2 Server, the batch below works fine when running double clicking the batch file from the desktop, however nothing happens when setting the .bat file to run as a task from Task Scheduler

@ECHO off

ECHO This .bat is used to automatically RDP in to the specified servers
ECHO which are contained within this file. Ensure you have logged in to
ECHO these servers beforehand and checked 'save credentials' otherwise
ECHO this batch file won't work as intended.
ECHO.
ECHO Beginning login...
ECHO.

ECHO Beginning login - Server ADMIN...
start mstsc.exe /v:00.00.00.00 /admin

PAUSE

The scheduled task is set to run under the Administrator account (only one available) and the (Start in) optional field has also been set "C:\Users\Administrator\Desktop\".

1
Does the job start if administrator is logged in? - Magoo
Where does the script start when you double click it on the desktop? That is, is the prompt c:\users\admin\desktop, or is it c:\windows\system32? It could be that you are inadvertently breaking it by forcing it to start on the desktop. - Tim
No it wasn't running with the administrator logged in, I tried testing this initially! - DanBarber
1. you could try providing the full path to mstsc.exe like: "C:\Windows\System32\mstsc.exe" (just guessing); 2. try to insert "" between start and the path like: start "" "C:\Windows\System32\mstsc.exe" /v:00.00.00.00 /admin (start might interprete the first argument as window title rather than a path); - aschipfl

1 Answers

1
votes

Turns out mstsc.exe only works if the user account is logged in... so under Security options in the General tab make sure 'Run only when user is logged in' is checked.