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?

  • What exactly is in this file? – Bob Oct 24 '13 at 13:23
  • Just key-value pairs that I want to change. I want to change the network configuration of a SQL Server instance. – Samuel Oct 24 '13 at 13:25
  • 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 Oct 24 '13 at 13:53

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.

| improve this answer | |
  • 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 Oct 24 '13 at 13:28
  • I think it's because I'm using the 32 bit version of Cygwin, and my registry keys are 64 bit – Samuel Oct 24 '13 at 13:58
  • @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 Oct 24 '13 at 14:07

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

unix2dos $reg
cmd /c "%SystemRoot%\regedit.exe \s `cygpath -w $reg`"
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.