What registry access can you get without Administrator privileges?

In general, a non-administrator user has this access to the registry: Read/Write to: HKEY_CURRENT_USER Read Only: HKEY_LOCAL_MACHINE HKEY_CLASSES_ROOT (which is just a link to HKEY_LOCAL_MACHINE\Software\Classes) It is possible to change some of these permissions on a key-by-key basis, but it’s extremely rare. You should not have to worry about that. For your purposes, your application … Read more

Updating every profile’s registry on Windows Server 2003

Active Setup is no longer advisable (original source). There are several ways to achieve what you want – one clunkier than the other. Terminal servers can be a deployment nightmare – users may not have rights to run msiexec.exe and hence MSI self-repair could fail. That’s why I generally prefer to use batch files, scripts … Read more

What are some alternatives to RegistryKey.OpenBaseKey in .NET 3.5?

For anyone who is interested in a C# solution for some of the previous versions of .NET in order to not have to refactor too much code, its not pretty but here it is, totally doable using reflection. I found this trick in the XSharper source code. public static class RegistryExtensions { public enum RegistryHiveType … Read more

How to add to and remove from system’s environment variable “PATH”?

Here’s something that does what you want which is similar to code in the jaraco.windows project. And like it, only uses built-in Python modules—so doesn’t require first downloading and installing the pywin32 extensions. Plus it’s Python 2.6+ and 3.x compatible and supports Unicode environment variables and values (directory paths in this case). Note that Windows … Read more

How to pass in multiple file/folder paths via a right-click event (verb) to an executable?

If you’re looking for a quick and dirty workaround, you can create a shortcut to your executable in ‘%AppData%\Microsoft\Windows\SendTo’ Now you can select a bunch of files, right click, select Send To, and your application. This will pass all the selected files as individual command line options to one instance of your application… keep in … Read more

How to associate a program with a file type, but only for the current user?

If you want to register the association for every user, write your data to HKEY_LOCAL_MACHINE\Software\Classes If you want to register the association for the current user only, write your data to HKEY_CURRENT_USER\Software\Classes This is how to do the latter: with TRegistry.Create do try RootKey := HKEY_CURRENT_USER; if OpenKey(‘\Software\Classes\.myfile’, true) then WriteString(”, ‘MyAppDataFile’); if OpenKey(‘\Software\Classes\MyAppDataFile’, true) … Read more

modifying the registry key value

It’s been a while I did reg hacks, but something like this could work: RegistryKey myKey = Registry.LocalMachine.OpenSubKey(“SOFTWARE\\Company\\Compfolder”, true); if(myKey != null) { myKey.SetValue(“Deno”, “1”, RegistryValueKind.String); myKey.Close(); }

Determine path to registry key from HKEY handle in C++

Use LoadLibrary and NtQueryKey exported function as in the following code snippet. #include <windows.h> #include <string> typedef LONG NTSTATUS; #ifndef STATUS_SUCCESS #define STATUS_SUCCESS ((NTSTATUS)0x00000000L) #endif #ifndef STATUS_BUFFER_TOO_SMALL #define STATUS_BUFFER_TOO_SMALL ((NTSTATUS)0xC0000023L) #endif std::wstring GetKeyPathFromKKEY(HKEY key) { std::wstring keyPath; if (key != NULL) { HMODULE dll = LoadLibrary(L”ntdll.dll”); if (dll != NULL) { typedef DWORD (__stdcall *NtQueryKeyType)( … Read more