Windows question-How does this registry commond work? - Page 1
Forum section: electronics / general

author: Logan
author_rank: Frequent Contributor
timestamp: May 16, 2021, 05:07:28 pm
content: 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!

author: DrG
author_rank: Super Contributor
timestamp: May 16, 2021, 05:27:51 pm
content: I am thinking that you saw and usedhttps://gist.github.com/ZigaBobnar/7ce7901b23b712ac38f51b98e40c6411I 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.htmlCaution: This could give you a headache quickly as well as cause you a lot of OS problems.

author: IanB
author_rank: Super Contributor
timestamp: May 16, 2021, 05:38:14 pm
content: 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.

author: Ian.M
author_rank: Super Contributor
timestamp: May 16, 2021, 05:41:23 pm
content: https://devblogs.microsoft.com/oldnewthing/20161117-00/?p=94735explainsCode: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.

author: Logan
author_rank: Frequent Contributor
timestamp: May 16, 2021, 06:15:14 pm
content: Quote from: IanB on May 16, 2021, 05:38:14 pmThanks but this is not going to run programs as admin, please read the OP again and see Ian.M's comment, he is right.

author: GlennSprigg
author_rank: Super Contributor
timestamp: May 30, 2021, 11:44:05 am
content: 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 anmsino chance, but anexethat extracts and installs then works fine."

author: Ian.M
author_rank: Super Contributor
timestamp: May 30, 2021, 01:11:34 pm
content: 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. Seehttps://ss64.com/nt/syntax-esc.htmlfor more details.Pick it apart by first working out what goes in the registry string value, then what cmd /C actually executes.