31

I have a shortcut to a program that only works when run as administrator but in the shortcuts advanced options "always run as administrator" is greyed out. I've looked at the other similar questions but none apply to my issue. UAC is enabled, I am an administrator and i have no idea how to run it in cmd.

14
  • 1
    The program is in a network? Programs in a network won't run as administrator.
    – Franchesco
    Feb 20, 2015 at 9:51
  • Of course you would prefer to set & forget "always run as administrator", but, until you get that working, you can right click the icon and select "run as administrator,", although you will have to do that every time that your want to run it. Feb 20, 2015 at 10:00
  • @Earendul The program isnt in a network.
    – man-qa
    Feb 20, 2015 at 11:51
  • @Mawg I'm not sure why but right click the shortcut doesn't bring up the option to run as admin, even though i can click the original .exe and run that as admin
    – man-qa
    Feb 20, 2015 at 11:52
  • 1
    @man-qa - Sounds like you are not actually an Administrator domain permissions overrule your local permissions.
    – Ramhound
    Feb 25, 2015 at 15:42

12 Answers 12

7

You may be able to use the run as administrator available on the compatibility tab.

One way third party way would be with nircmd. http://www.nirsoft.net/utils/nircmd2.html#elevate

3
  • The author indicated this option is grayed out.
    – Ramhound
    Feb 25, 2015 at 15:27
  • 3
    No they did not. They stated the option was greyed out on the advanced options on the shortcut tab. I was referring to the spot on the compatibility tab. Feb 25, 2015 at 18:58
  • @birdman3131 Wow i didn't expect this to work but it did. Thanks birdman :)
    – man-qa
    Feb 26, 2015 at 11:53
13

It works if you add the executable to the shortcut target. For example:

Right-click on the shortcut and change the target from:

C:\Scripts\helloworld.js

to

wscript.exe C:\Scripts\helloworld.js

(or)

cscript.exe C:\Scripts\helloworld.js

Then the Run as Administrator checkbox is activated in properties.

Eg:

for a python script add in the target field:

"C:\Users\......\Python36\python.exe" "C:\Users\......\test.py"

For PowerShell script add this in the target:

powershell.exe -command "& 'C:\A path with spaces\MyScript.ps1'"

(if you want to also pass some args see this)

Don't forget to check the "run as admin" after...

All the glory to Ramesh Srinivasan

3

It seems as though the "run as administrator" context menu option and/or shortcut checkbox are unavailable for batch files/scripts. This was answered for PowerShell here: How to run script as administrator?

I don't have an answer yet for running a common batch file.

2

This seems to happen when a shortcut points to an object identifier rather than a directory path.

You can tell if this is the case because the target in the shortcut properties is something like {0AFACED1-E828-11D1-9187-B532F1E9575D} instead of a directory path.

If you want to create a shortcut to something in C:\Windows\System32, create the shortcut directly off an item in that folder, rather than trying to create it from an existing shortcut on the start menu.

3
  • That's not the only way this can happen; I think it can also happen when you need admin in order to modify the shortcut file. At any rate, I'm seeing this with a path-based shortcut that was put on my start menu by an installer. Oh, it could also be because the target is an .ini file, not an executable...
    – SamB
    Dec 14, 2015 at 18:50
  • When I try creating a shortcut to hosts, it says cannot create shortcut here, would you like it on the desktop instead; but why am I suffering through this even when I am admin on this box ??
    – killjoy
    May 2, 2017 at 11:21
  • I have this problem on a python script shortcut
    – JinSnow
    Oct 15, 2018 at 14:37
2

This seems to happen with file types windows doesn't recognize/trust. But I just found a simple solution for this.

Make a shortcut to cmd.exe (c:\windows\system32\cmd.exe), and replace the Target field with this

C:\windows\System32\cmd.exe /c start "" "c:\path\to\your.file"

Now you should be able to enable the "Run as administrator" on the Advanced tab

Caveats:

  • On windows 10, running as administrator seems to have a different set of network drives, try to use absolute UNC paths rather than mapped drives
  • If you need to pass parameters please check here for some documentation for the Start command

Why do we use Start instead of just opening it with cmd.exe?

  • If you just run the file using a shortcut to cmd.exe /c c:\path\to\your.file, you're stuck with an empty black window open so long as your program is running

How does using Start work around this?

  1. It starts a cmd instance with the /c flag which closes it after it's command finishes running
  2. It then runs Start which is a native command in cmd.exe that opens a "program" in a new window
  3. The way the Start command works if it's not an executable the launch gets passed up to Windows, which then opens it using the associated program for that file type
  4. Once the launch is started, the Start command ends which then lets the cmd.exe window close
1

The fix is to create a shortcut to the executable that needs to be run as admin (if you want to workaround the ugly code for invoking the UAC prompt). After creating the new shortcut, right-click on it and select Properties, then click the Shortcut tab, then the Advanced... button and finally check the Run as Administrator checkbox.

1
  • This is a nice little workaround. I was able to make a shortcut to my "hosts" file using this technique with Visual Studio Code. Example shortcut: "C:\Users\quantastical\AppData\Local\Programs\Microsoft VS Code\Code.exe" "C:\Windows\system32\drivers\etc\hosts"
    – jeffjenx
    Jan 3, 2019 at 2:38
1
  1. Go to the properties of shortcut file
  2. Click on shortcut tab
  3. add "powershell.exe" before the path of file in Target

it should look like below:

powershell.exe -file "H:\Powershell\MyPoshScript.ps1"

  1. Click apply
  2. Click advance button
  3. Run as administrator now selectable.
  4. Check Run as administrator and apply --> OK

Done

reference from: How to run script as administrator?

1
  • This option worked for me trying to start a service. Shortcuts to both a batch file running net start Spooler and a Powershell script running Start-Service Spooler both had Run as Administrator greyed out. Changing the shortcut target to cmd.exe /c "blah" and powershell.exe -file "blah" worked.
    – AlainD
    Apr 23, 2022 at 10:31
1

This is the solution (example for Word 2016, Windows 10)

  1. Don't use the regular shortcut
  2. Find the main file (for Word 2016 : "C:\Program Files\Microsoft Office\Office16\WINWORD.EXE")
  3. Make a shortcut with "Send to the desktop as a shortcut"
  4. Now you will see that "Always run as an administrator" option is not greyed out.
0

I had this issues on a Windows Server 2008 R2 SP1 system when running shortcuts to run batch files/VBScripts to sync and eject USB disks, or to shutdown Hyper-V systems in preparation for staff to reboot the server cleanly.

Found when I right-clicked the icon, selected properties, then selected the Advanced button next to Change Icon. Select the Run As Administrator option then Save. If UAC is enabled, it will still ask for permission to run, but it will now run properly.

0

My icon was copied to the quick launch bar. The option to run as administrator was greyed out. So I started again and I deleted the shortcut i had previously tried to set.

This is how i solved the issue.

Opened my start menu, found the icon I wanted, properties, open file location. (This opened the file location of the shortcut from my start menu - perfect).

Now I selected the shortcut icon and copied it.

I then right click on my quick launch bar, "Open Folder" and pasted a copy of my shortcut there.

Now I have access to set it to run as administrator.

0

BrianD gave the best answer and Ross in How to run script as administrator? explained it:

Instead of using the compatibility tab (where the option is greyed out ) use the Advanced button on the Shortcut Tab

This is valid for Windows7 at least.

0

I was trying for Control Panel to "Run as admin", but it was greyed out for a standard user. Solved by opening C:\Windows\System32, right-clicked on Control and created the shortcut on the desktop. Now this shortcut is available with "Run as administrator" on right-click.

1
  • Your question does not directly answer the question. Please add it as a comment to the question instead. Feb 17, 2021 at 15:49

You must log in to answer this question.

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