0

I'm trying to use group policy to replace the default windows Powershell shortcut with one that automatically checks the advanced option for the default shortcut: 'Run as Administrator' that can be found when editing the properties of the shortcut. Shown as followed, Powershell shortcut advanced options.

However in group policy, the settings for shortcuts are limited. You may provide arguments, but that is all. and I suspect that it is an argument in the default shortcut that allows it to run as Administrator because besides giving arguments and a starting directory to a shell there is nothing else to it besides the shell. (See picture) Group policy shortcut options

Unfortunately, windows does not show what arguments are provided to the default shortcut that allow it run as administrator. Shortcut details

So if someone could tell me what arguments the shortcut has that allow it to do 'Run as Administrator' I would greatly appreciate it. Thank you.

  • Actually, this is defined by byte #21 in the saved shortcut file.. If the value of that byte is 0x22, the `Run as Administrator` is set. You could use my function [New-Shortcut](https://stackoverflow.com/a/57547816/9898643) to achieve that – Theo Aug 10 '20 at 13:34
  • @Theo actually it's not. See **[MS-SHLLINK]-170915.pdf** at page 13, there is only 1 bit responsible to this. – filimonic Aug 10 '20 at 13:45
  • @filimonic You're right. I have edited [my function](https://stackoverflow.com/a/57547816/9898643) – Theo Aug 10 '20 at 13:53

1 Answers1

0

There is unsupported usy-at-your-own-risk method - setting byte #21 to 34

There is also more argumented method doing this ( I think it is better, because it takes into account old binary value )

Alternatively, to use from PowerShell you should find a wrapper around WinApi methods to set SLDF_RUNAS_USER flag for shortcut.

I think, you should test second method to use in PowerShell

There is no native way doing this from any .net-based language.

Documentation: MS-SHLLINK

filimonic
  • 3,988
  • 2
  • 19
  • 26