Modifying registry from Cygwin not working

1

I'm trying to import a .reg file from Cygwin shell using

regedit.exe <registryfile>.reg

The dialogs pop up asking if I want to apply the registry changes, and I click yes, but no changes are made. If I run the exact same command through command prompt or by double-clicking the .reg file, the changes are applied correctly. What is it about Cygwin that would prevent regedit from working, and how can I go about modifying the registry from Cygwin?

I found out that my changes were being applied, but to some other dat file somewhere. When I just call regedit from Cygwin, I get a bunch of different keys than I would expect (for example all MSSQL keys are not there, but many other keys are)... Why does Cygwin open a different file?

Samuel

Posted 2013-10-24T12:45:20.630

Reputation: 135

What exactly is in this file? – Bob – 2013-10-24T13:23:28.113

Just key-value pairs that I want to change. I want to change the network configuration of a SQL Server instance. – Samuel – 2013-10-24T13:25:09.107

you write "When I just call regedit from Cygwin, I get a bunch of different keys than I would expect" What keys exactly? (that would help as it'd enable somebody else to try to reproduce what you see) – barlop – 2013-10-24T13:53:36.327

Answers

2

Parts of this answer assume that you are running a 64-bit version of Windows.

Windows has a few registry redirections in place, which make it appear different depending on the environment you are viewing it from. The most prominent are HKEY_CURRENT_USER, which is loaded depending on the user profile in use, and the redirection for 32-bit processes - an example is the Wow6432Node key under SOFTWARE, which is what 32-bit applications see when they look for the SOFTWARE key.

Most likely, your Cygwin process is actually running under a different user and therefore launching regedit under this user. Otherwise, it could be due to running in 32-bit mode - without knowing which specific keys you are targeting, I cannot say for sure. There might also be other redirections I'm not aware of.

For more information on 32-bit (WOW64) registry redirection, see here.

There's a list of redirected keys here.

For programmers, there are flags you can use to access a specific version of the registry. For the rest of us, run the appropriate version of Regedit - at least on Windows 7 and 8, %SystemRoot%\regedit.exe is always the 64-bit version and %SystemRoot%\SysWOW64\regedit.exe is always the 32-bit version.

Bob

Posted 2013-10-24T12:45:20.630

Reputation: 51 526

I'm looking only at HKEY_LOCAL_MACHINE/SOFTWARE. Would this still impact which registry I see, and where can I learn more about the redirections? – Samuel – 2013-10-24T13:28:47.450

I think it's because I'm using the 32 bit version of Cygwin, and my registry keys are 64 bit – Samuel – 2013-10-24T13:58:56.947

@Samuel That's probably it. Trying to access HKEY_LOCAL_MACHINE\SOFTWARE from a 32-bit process will automatically give you HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node instead. You could try launching the 64-bit regedit directly - use the full path (\Windows\regedit.exe). You're basically trying for the opposite of this answer.

– Bob – 2013-10-24T14:07:03.017

0

To import a file called /tmp/file.reg into the registry using Cygwin bash try:

reg=/tmp/file.reg
unix2dos $reg
cmd /c "%SystemRoot%\regedit.exe \s `cygpath -w $reg`"

M Smith

Posted 2013-10-24T12:45:20.630

Reputation: 101