Author Topic: Windows question-How does this registry commond work?  (Read 1759 times)

0 Members and 1 Guest are viewing this topic.

Offline LoganTopic starter

  • Frequent Contributor
  • **
  • Posts: 345
  • Country: us
Windows question-How does this registry commond work?
« on: May 16, 2021, 05:07:28 pm »
Hello guys.

So here is a .reg file which add a option on your right click menu, to allow you to run programs needing admin privilege as normal user, without UAC prompt:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\*\shell\forcerunasinvoker]
@="Run without privilege elevation"

[HKEY_CLASSES_ROOT\*\shell\forcerunasinvoker\command]
@="cmd /min /C \"set __COMPAT_LAYER=RUNASINVOKER && start \"\" \"%1\"\""


It does works well. But I don't know how it works, especially the last line with lots of symbols... Can anyone explain that?

Thanks a lot!
 

Offline DrG

  • Super Contributor
  • ***
  • !
  • Posts: 1199
  • Country: us
Re: Windows question-How does this registry commond work?
« Reply #1 on: May 16, 2021, 05:27:51 pm »
I am thinking that you saw and used https://gist.github.com/ZigaBobnar/7ce7901b23b712ac38f51b98e40c6411

I would answer you like this. Those registry values don't do anything at all on their own but they act like variables that the OS uses for all sorts of things. So, you really need to know how the OS is using those keys.

To understand "the last line with lots of symbols" you need to start looking at the syntax required to mess around (e.g., assign values to keys in an editor/ file) with this stuff - see, for example, https://ss64.com/nt/reg.html

Caution: This could give you a headache quickly as well as cause you a lot of OS problems.
« Last Edit: May 16, 2021, 05:31:31 pm by DrG »
- Invest in science - it pays big dividends. -
 
The following users thanked this post: Logan

Offline IanB

  • Super Contributor
  • ***
  • Posts: 11771
  • Country: us
Re: Windows question-How does this registry commond work?
« Reply #2 on: May 16, 2021, 05:38:14 pm »
There should already be a "Run as administrator" option on your right click mouse menu in Windows 10, without making any registry changes?

As for what all those symbols mean, you can get a start by opening a command prompt and typing "help cmd".

By the way, bypassing UAC is a really bad idea. Don't do that unless you like to live dangerously.
 
The following users thanked this post: Logan

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12753
Re: Windows question-How does this registry commond work?
« Reply #3 on: May 16, 2021, 05:41:23 pm »
https://devblogs.microsoft.com/oldnewthing/20161117-00/?p=94735
explains
Code: [Select]
set __COMPAT_LAYER=RUNASINVOKERN.B. It does *NOT* bypass UAC and does *NOT* let you run programs that *NEED* admin privileges.  Instead it lies to programs that *THINK* they need admin privileges so they'll run until/unless they actually need admin privileges at which point they'll either silently fail or error out.
 
The following users thanked this post: newbrain, Logan

Offline LoganTopic starter

  • Frequent Contributor
  • **
  • Posts: 345
  • Country: us
Re: Windows question-How does this registry commond work?
« Reply #4 on: May 16, 2021, 06:15:14 pm »
There should already be a "Run as administrator" option on your right click mouse menu in Windows 10, without making any registry changes?

As for what all those symbols mean, you can get a start by opening a command prompt and typing "help cmd".

By the way, bypassing UAC is a really bad idea. Don't do that unless you like to live dangerously.

Thanks but this is not going to run programs as admin, please read the OP again and see Ian.M's comment, he is right.
 

Offline GlennSprigg

  • Super Contributor
  • ***
  • Posts: 1259
  • Country: au
  • Medically retired Tech. Old School / re-learning !
Re: Windows question-How does this registry commond work?
« Reply #5 on: May 30, 2021, 11:44:05 am »
I'm not sure about the workings of the individual 'back-slashes' etc, however, if you Google even just this part...
  RUNASINVOKER && start \"\" \"%1\"\""
then you will find countless links to "Forcing a program to run, without Admin privileges"...
One of the responses from a Developer, is this...
"This is right, i use it at work for users who don’t have admin rights but want to update the application and we don’t want them calling us all the time just for that.
Also it doesn’t work for every application. If it’s an app the downloads and install an msi no chance, but an exe that extracts and installs then works fine.
"
Diagonal of 1x1 square = Root-2. Ok.
Diagonal of 1x1x1 cube = Root-3 !!!  Beautiful !!
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12753
Re: Windows question-How does this registry commond work?
« Reply #6 on: May 30, 2021, 01:11:34 pm »
That would depend on *where* said exe extracts and installs.  If any of the folders it tries to create or modify files in, or any registry keys require admin privileges, it will fail.  See #3 above. 

For completeness, \ is the regedit escape character used in .reg files, used here to put literal " within string values which in .reg files use " as the string delimiters, and the multiple " in the string value  are how you escape a " by doubling it in a quoted parameter on the CMD command line.  See https://ss64.com/nt/syntax-esc.html for more details.
Pick it apart by first working out what goes in the registry string value, then what cmd /C actually executes.
« Last Edit: June 11, 2021, 07:10:03 pm by Ian.M »
 
The following users thanked this post: GlennSprigg


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf