3

When I right click on some .bat files the "run as administrator" selection is bold. Why is this?

How do I make it so that all .bat files act that way too?

4
  • Are you talking about in the right-click context menu? Bold usually means that's the default option if you double-click on the file. Sep 26, 2014 at 19:53
  • @DarthAndroid yup the right-click context menu, how do i make other .bat files behave the same way?
    – ljk
    Sep 26, 2014 at 20:06
  • Can you provide some examples of the names of the .BAT files that do and don't have the bold Run as administrator option? Sep 27, 2014 at 14:26
  • @Twisty thanks for replying, the files i have are shortcuts of files that i created, so i don't think naming is the issue here :|
    – ljk
    Sep 27, 2014 at 23:24

1 Answer 1

1

Answer 1:

Individual .BAT files can be configured to always Run as administrator by creating a shortcut to the batch file and modifying the shortcut's properties. Here's how:

  1. Create a shortcut to the batch file
  2. Right-click the shortcut and choose Properties
  3. On the Shortcut tab click Advanced
    enter image description here

  4. Select the Run as administrator checkbox enter image description here

  5. Click OK twice to save and exit


Answer 2:

The solution above is great if you don't mind all the extra steps. But why work so hard? You can configure all .BAT files to default to the Run as administrator option. It only requires a simple registry edit:

  1. Save the following code snippet into a file named DefaultToRunas.reg

    Windows Registry Editor Version 5.00
    
    [HKEY_CLASSES_ROOT\batfile\shell]
    @="runas"
    
  2. Double-click the DefaultToRunas.reg file to merge the settings into the Windows Registry

  3. Click Yes if prompted by UAC
  4. Click Yes to merge the changes into the Registry

    Notes:

    • I've confirmed this works on Windows 7, Windows 8 and Server 2008 R2
    • This setting change affects all users of the computer

What About Other File Types?

You can use this registry edit to change the default for other file types as well. For example, to make Run as administrator the default action for command files (.CMD), substitute the following registry file in Step 1 above:

    Windows Registry Editor Version 5.00

    [HKEY_CLASSES_ROOT\cmdfile\shell]
    @="runas"

You can read more about manipulating the Windows Context menu in this MSDN article.

2
  • thanks for the detailed reply! I guess I didn't look through all the tabs in the context menu enough before
    – ljk
    Oct 1, 2014 at 16:40
  • You're welcome. Figuring out how to get one batch script to run as admin was easy. It took me several hours to find out how to make all batch files always run as Administrator. Thanks for the challenging question! Oct 1, 2014 at 16:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .