16

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

0

6 Answers 6

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"
2
  • 1
    +1 Could be, perhaps he did some international input that uses different characters. Mar 25, 2012 at 21:16
  • I didn't notice that! You're right I copied it off the net, thank you!
    – Aximili
    Mar 26, 2012 at 11:16
35

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.

4
  • But aximili shouold be sure that this file is unicode. REGEDIT4 should be used for ansi files.
    – crea7or
    Mar 25, 2012 at 13:23
  • 1
    @crea7or: The file does not need to be Unicode for what he is trying to insert. Mar 25, 2012 at 13:28
  • 3
    This answer is the correct one. Feb 10, 2014 at 13:14
  • As Gras Double says, this answer is the correct one.
    – pdwalker
    Jan 21, 2017 at 5:58
9

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

3

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.

0
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.

0

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

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.