My task has been pretty simple: I have needed to run a batch file with a lot of Robocopy commands. The issue I have faced is usual for Windows Vista, Windows 7 or Windows Server 2008:
ERROR: You do not have the Backup and Restore Files user rights.
Yes, if I right click on the batch file and select Run As Administrator, everything works fine. My goal has been to run this batch file from the command line without user interaction at all. At the same time I have needed not to compromise security
RunAs does not help at all. In order to get the privileges elevated the Administrator user has to be used, but this user is disabled by default and I do not want to enable it.
I have tried to change batch file properties and set up Run This Program As an Administrator, but this checkbox has been disabled. I have done this for Robocopy.exe, but it makes situation even worse: UAC asks its question every time the batch file runs robocopy.
Finally, I have found the solution
I have created a scheduled task called RunBatch to run my batch file. I have not set up any schedule for it; I have checked the Run on highest privileges box on General tab and saved the task.
SCHTASKS /run /tn RunBatch
runs the job with elevated privileges and without asking any question