Why Can't I run a FreeFileSync batch file as Administrator?

6,655

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:
6,655

Related videos on Youtube

SMTF
Author by

SMTF

Updated on September 18, 2022

Comments

  • SMTF
    SMTF almost 2 years

    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.

  • surfasb
    surfasb over 12 years
    There are so many caveats to running a process as SYSTEM that there are too many to list. This is not a safe method.
  • SMTF
    SMTF over 12 years
    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".
  • surfasb
    surfasb over 12 years
    Did you even look at the example scripts??
  • surfasb
    surfasb over 12 years
    @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
    surfasb over 12 years
    @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.
  • skub
    skub over 12 years
    Oh I didn't know he was on a domain.
  • SMTF
    SMTF over 12 years
    The issue is not the simplicity of the script but the need for the powertoy dependency. Your suggestion is informative and I thank you.
  • surfasb
    surfasb over 12 years
    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
    surfasb over 12 years
    @skub: I have no idea either. Never the less, that link only works when 1) the builtin admin account is enabled 2) the Admin Approval Mode is turned on. Domain joined computers will have these settings off - usually.