Home > Uncategorized > “The specified file is not a registry script” – How encoding can ruin your morning

“The specified file is not a registry script” – How encoding can ruin your morning

If you’re like me, you spend a lot of time dealing with files and text files are no exception. Doing anything powerful while editing a text file usually isn’t handled by basic programs like Notepad. What editor to use is a bit of a holy war that I won’t get into since it has little to do with this blog entry. Having said that, I prefer to use a powerful editor when dealing with text files because I find that all too often Notepad just doesn’t get the job done as quickly, so I use TextPad. It has several features that I find myself using all too often, so I’ve set it as my default text editor.

This morning I was doing some development and I had to quickly create a (.reg) registry file with which I could quickly set some values in the registry when I needed to. This seemed like a simple enough operation. For the sake of speed, I already had regedit open to the path that I was interested in, so I chose to export it from regedit. Doing so saved a .reg file where I specified and I was free to edit it. I opened up TextPad and make the changes that I needed. In my case I was only changing a single key so I cut everything else out and saved the file. To test things out, I double-clicked on the .reg file and got the typical prompt:

Registry File Import Prompt

I just made this file, so I did in fact trust it and by clicking “Yes” I expected to get a valid message like this:

Registry File Import

However, instead I got this:

Registry File Import Failed

What the heck? That’s not good! This simple was dirt simple. After all it only had 3 lines in it. What could have happened? 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:

Registry File Textpad Save As

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.

Advertisement
Categories: Uncategorized
  1. Kevalin
    February 7, 2011 at 10:52 pm | #1

    Exceedingly glad this worked for you… but nothing I’ve tried will let me install this script in the registry. ANSI or Unicode, it insists that I can only import registry files from a binary editor.

    Nice try, though.

    • crmdev
      February 8, 2011 at 12:53 am | #2

      Nice try indeed. I can pretty much guarantee you that if you created your file by hand in Notepad that it should work. If not, you’re either facing an encoding issue or it’s not in the correct format that it expects. Considering the error message, I’d go with the former. Try looking at the file in a hex editor and see what you get.

  2. Dale
    April 13, 2011 at 8:20 pm | #3

    Sir, your solution for the registry regarding ANSI was perfect. It solved my problem. The other thing I had to do was specify “all files” as it wanted to save it as “txt”.

    Thank you very much!

    Dale

  3. Apneram
    July 19, 2011 at 11:16 am | #4

    This is great! Thank you very much!! It solved my problem that I was stuck on for few days and no amount of googling gave me the answer you have provided in a lucid way.
    Thanks again!

  4. July 23, 2011 at 1:23 am | #5

    Yep, just run into this – tested alongside notepad (export – open in editor (np/tp) – add a space and then delete it again so can save – save – import – which worked fine for np and fails with tp) – took me a while to work it out, then thought I’d moan to TextPad – but found your post (if only I had found it 3 hours ago!)

  5. November 17, 2011 at 10:13 am | #6

    thanks so much for this information!

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.