Add Take Ownership to Right-click (context) Menu - Seeking Explanation, Please

It's a simple text file that was turned into a reg key that contains commands that add the option to take ownership of a file to the right-click context menu on a file or folder, nothing more.
 
Hi Patrick,

It's a simple text file that was turned into a reg key...

Thanks for the reply.:smile9:

Re-stating my question: Please explain what each line of modification to the registry is doing functionally. For example, looking at the first modified key:
Code:
[HKEY_CLASSES_ROOT\*\shell\runas]
@="Take Ownership"
"NoWorkingDirectory"=""

I see this conditions the default value of HKEY_CLASSES_ROOT\*\shell\runas\command which allows a subsequent line to change the default to become c takeown but I'm not familiar with the "NoWorkingDirectory"="" part of this modification. Also, how does this key relate to the context menu in Windows Explorer?

Here's the complete contents of the .REG file:
Code:
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\*\shell\runas]
@="Take Ownership"
"NoWorkingDirectory"=""

[HKEY_CLASSES_ROOT\*\shell\runas\command]
@="cmd.exe /c takeown /f \"%1\" && icacls \"%1\" /grant administrators:F"
"IsolatedCommand"="cmd.exe /c takeown /f \"%1\" && icacls \"%1\" /grant administrators:F"

[HKEY_CLASSES_ROOT\Directory\shell\runas]
@="Take Ownership"
"NoWorkingDirectory"=""

[HKEY_CLASSES_ROOT\Directory\shell\runas\command]
@="cmd.exe /c takeown /f \"%1\" /r /d y && icacls \"%1\" /grant administrators:F /t"
"IsolatedCommand"="cmd.exe /c takeown /f \"%1\" /r /d y && icacls \"%1\" /grant administrators:F /t"

I'd appreciate a line-by-line explanation of how the OS reacts to these modifications in the registry as they relate to the Explorer context menu.

Maybe if I understand how these modifications are working, I can write my own .REG file to perform some other tasks.

Again, I apologize if this post belongs in a different forum.

Thank you.
 
I'm not familiar with the "NoWorkingDirectory"="" part of this modification.

It's not well documented, see - https://msdn.microsoft.com/en-us/li...cessstartinfo.workingdirectory(v=vs.110).aspx

It's a property of ProcessStartInfo. With WorkingDirectory set, you can default to system32 for the command being run and avoid the current directory becoming the working directory when you right-click (as it starts a new process). NoWorkingDirectory is used when you don't want the right-click item (location) to become part of the environmental path regarding the script. If you change NoWorkingDirectory to WorkingDirectory in that short script, it'll still run. To be honest I have no idea why NoWorkingDirectory was even used in this script's case.

As far as IsolatedCommand goes, no clue. Undocumented registry value.

The rest of the commands can be googled and are better than me explaining, really, unless you actually cannot find something.
 
Hi Patrick

Thank you for the quick response. :smile9:

As far as IsolatedCommand goes, no clue. Undocumented registry value.

The rest of the commands can be googled and are better than me explaining, really, unless you actually cannot find something.

This page confirms what you said: What is the "IsolatedCommand" registry value? What purpose does it serve? - Super User

Excerpt:
Unfortunately, I can't find any documentation for the IsolatedCommand key (I've consulted both TechNet and MSDN) but from its name, I'd guess that it controls how a process is created. I can tell you that it is normal and required in the HKLM hive.

BTW, I merged the .REG file into my registry on this PC. It works as designed. My thanks to jcgriff2! :thumbsup2:
 

Has Sysnative Forums helped you? Please consider donating to help us support the site!

Back
Top