Creating a .reg file for Windows 7

16

2

I created a .reg file but when I double-click it, it doesn't want to be imported.

The specified file is not a registry script.You can only import binary registry files from within the registry editor.

Here is the content of the .reg file

[HKEY_CLASSES_ROOT\Folder\shell\PngCrush]
@=”PNG Crush”

[HKEY_CLASSES-ROOT\Folder\shell\PngCrush\command]
@=”E:\Programs\PNGCrush\crush.bat %1”

Could someone help me? Thanks in advance

Aximili

Posted 2012-03-25T12:51:21.540

Reputation: 573

Answers

6

I don't know how those quotes ended up in that file, but I would assume those don't work (maybe you copied it off a Wordpress blog).

Besides anything else, I think it should be like this:

[HKEY_CLASSES_ROOT\Folder\shell\PngCrush]
@="PNG Crush"

[HKEY_CLASSES-ROOT\Folder\shell\PngCrush\command]
@="E:\Programs\PNGCrush\crush.bat %1"

Der Hochstapler

Posted 2012-03-25T12:51:21.540

Reputation: 77 228

1+1 Could be, perhaps he did some international input that uses different characters. – Tamara Wijsman – 2012-03-25T21:16:19.050

I didn't notice that! You're right I copied it off the net, thank you! – Aximili – 2012-03-26T11:16:26.617

34

That's not the valid syntax of a registry file, it's missing the header.

Add a line in front with: Windows Registry Editor Version 5.00

Check whether there are invalid characters, if you saved the file in Unicode that could be the problem.

Tamara Wijsman

Posted 2012-03-25T12:51:21.540

Reputation: 54 163

As Gras Double says, this answer is the correct one. – pdwalker – 2017-01-21T05:58:14.303

But aximili shouold be sure that this file is unicode. REGEDIT4 should be used for ansi files. – crea7or – 2012-03-25T13:23:22.577

1@crea7or: The file does not need to be Unicode for what he is trying to insert. – Tamara Wijsman – 2012-03-25T13:28:28.460

3This answer is the correct one. – Gras Double – 2014-02-10T13:14:11.220

8

Just compiling all the answers together with some extra info I discovered.

Header on the first line: Windows Registry Editor Version 5.00

  • A blank line between keys delimited by "CRLF"
  • keys brackets without spaces
  • values in double quotes
  • integer/word values in hex - lowercase for the letters apparently

Example

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\MyOrg]

[HKEY_LOCAL_MACHINE\SOFTWARE\MyOrg\MyKey]
"My Value"="Some String"
"My Flag or Integer"=dword:00000001

The allowed encodings also seems to correspond to the Windows API strings which are:

  • 8-bit fixed width: Windows-1252 - almost the same as ISO-8859-1
  • 16-bit fixed width: UCS-2LE (little endian) - basically the same as UTF-16

Note: when a text editor says "unicode" for the encoding, it probably means UTF-8 which is a variable width encoding not naively compatible with internal Windows.

Note 2 (edit): ASCII is 7-bit and all the processors I know of in use are a power of 2 bits so it's always going to be wrapped in some other ASCII superset like 1252. #thingsyoulearnafteruni

Seth

Posted 2012-03-25T12:51:21.540

Reputation: 181

4

Take a look at this website, it helped me with this problem: “The specified file is not a registry script” – How encoding can ruin your morning

Turns out that encoding can ruin your morning. Taking a look at the message I saw the “… only import binary registry files from …” and I thought “Why does this thing think it’s binary?”. Why, indeed. I opened the file back up in TextPad and rather than just hitting Ctrl+S or Save, I chose "Save As". Doing so presented this menu, and I’ve highlighted my problem:

That’s right. Without me doing anything, TextPad was going to save this file as Unicode. Regedit expects to get .reg files that are ANSI encoded. So I changed the Encoding to ANSI, saved the file, ran it again, and everything worked fine. It caused me some frustration for a good 20 minutes, so hope this helps someone else out.

Vitumbiko Smith Nkhwazi

Posted 2012-03-25T12:51:21.540

Reputation: 41

1

I had the same problem because I saved it as UTF-8-BOM. It should be UTF-8 without BOM (Byte Order Mark). It's worth noting.

Paweł Walaszek

Posted 2012-03-25T12:51:21.540

Reputation: 111

0

You can also use the REG utility to manipulate registry via command line, if it fits your needs.

lrosa

Posted 2012-03-25T12:51:21.540

Reputation: 186