Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I've created a FreeFileSync batch script with options that will preserve file permissions, this requires the script to be run with Administrative Privileges. I can't find an obvious way to run the script as an admin and because of that I created a shortcut to the script and attempted to have the new shortcut run as an admin, trouble is, the option to "Run as administrator" is grayed out.

How can I schedule my FreeFileSync batch to run periodically as the Administrator?

Thanks in advance.

share|improve this question

2 Answers 2

There used to be an old hack where you could elevate to the system account by using the task scheduler, I think this is no longer the case since Microsoft closed that hole in Windows 7. However, I'm pretty sure you can still do this and create a shortcut that will run the program as administrator. The instructions are for vista, but the article suggests that they should be valid for windows 7 - I speculate the same thing.

EDIT: here is the link to the win 7 instructions I deleted the other instructions.

share|improve this answer
1  
There are so many caveats to running a process as SYSTEM that there are too many to list. This is not a safe method. –  surfasb Jan 15 '12 at 6:01
1  
You're not running the process as system, it's only how the process is originally dispatched. –  skub Jan 15 '12 at 6:14
    
@skub Thanks. That is a well detailed answer; however, I'm not prepared to hammer something together for a task this minor. –  SMTF Jan 15 '12 at 19:44
    
@skub. It still doesn't solve the problem. When FreeFileSync is being launched from the batchfile, it is run with limited user access, unless the program specifies it, or you elevate the program by calling ShellExecute(). Which is why you can't do this using just a batch file. The easiest way to to simply call the program using one of the 100s of prewritten VBscipts or JScripts that call ShellExecute(application, args, "runas"); This is a fundamental misunderstanding of UAC. –  surfasb Jan 15 '12 at 23:25
    
@skub: Your link also will not work with Computers who's Admin accounts are disabled or where Admin Approval Mode is turned off, which is off by default if a Vista/7 computer is joined to a Domain. –  surfasb Jan 15 '12 at 23:27

The batchfile is being elevated.

What is happening is you are launching another process(FreeFileSync) from the batchfile. Unlike commands in a Command Prompt, which run inside the Command Interpretor, the new process is run as a User by default.

To elevate commands inside a batchfile, you'll need to use VBScript or JScript and the Windows Scripting Host. My recommendation is to use the Elevation PowerToy for Vista. The download contains example scripts.

You can also read the articles and example scripts on the website also.

share|improve this answer
    
Thanks for the clarification. In this case preserving the file permissions is not so big a deal as to include a new dependency. Really I was looking for something only a little more complicated then "sudo". –  SMTF Jan 15 '12 at 19:46
    
Did you even look at the example scripts?? –  surfasb Jan 15 '12 at 23:08
1  
The issue is not the simplicity of the script but the need for the powertoy dependency. Your suggestion is informative and I thank you. –  SMTF Jan 16 '12 at 22:40
    
The powertoys are merely scripts who's lines you can incorporate into you own. You don't install them in the traditional sense. But they include inf files for the convenience. –  surfasb Jan 16 '12 at 23:03

Your Answer

 
discard

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.