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.
12 Answers
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
-
-
3No 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-qaFeb 26, 2015 at 11:53
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
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.
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.
-
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...– SamBDec 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 ??– killjoyMay 2, 2017 at 11:21
-
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.
-
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"
– jeffjenxJan 3, 2019 at 2:38
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?
- It starts a cmd instance with the
/c
flag which closes it after it's command finishes running - It then runs
Start
which is a native command in cmd.exe that opens a "program" in a new window - 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 - Once the launch is started, the
Start
command ends which then lets the cmd.exe window close
- Go to the properties of shortcut file
- Click on shortcut tab
- add "powershell.exe" before the path of file in Target
it should look like below:
powershell.exe -file "H:\Powershell\MyPoshScript.ps1"
- Click apply
- Click advance button
- Run as administrator now selectable.
- Check Run as administrator and apply --> OK
Done
reference from: How to run script as administrator?
-
This option worked for me trying to start a service. Shortcuts to both a batch file running
net start Spooler
and a Powershell script runningStart-Service Spooler
both hadRun as Administrator
greyed out. Changing the shortcut target tocmd.exe /c "blah"
andpowershell.exe -file "blah"
worked.– AlainDApr 23, 2022 at 10:31
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.
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.
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.
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.
-
Your question does not directly answer the question. Please add it as a comment to the question instead. Feb 17, 2021 at 15:49
This is the solution (example for Word 2016, Windows 10)
- Don't use the regular shortcut
- Find the main file (for Word 2016 : "C:\Program Files\Microsoft Office\Office16\WINWORD.EXE")
- Make a shortcut with "Send to the desktop as a shortcut"
- Now you will see that "Always run as an administrator" option is not greyed out.
Administrator
domain permissions overrule your local permissions.