Jump to content

REGISTER EXTENSIONS!


Frozenyam
 Share

Recommended Posts

Currently the code allows you to register the ".ref" extension completely, including adding it to the right-click desktop menu to create new. Go through code and change ".ref" to whatever extension you like and you can register whatever enxtension you like. You can also change the icon if you so desire. I will make this a UDF for easy creation later. I hope you all enjoy! :dance:

;----- HKEY_CLASSES_ROOT ----->

RegWrite ("HKCR\.ref", "", "REG_SZ", "ReferenceFile")
RegWrite ("HKCR\.ref", "PerceivedType", "REG_SZ", "Text")
RegWrite ("HKCR\.ref\PersistentHandler", "", "REG_SZ", "{5e941d80-bf96-11cd-b579-08002b30bfeb}")
RegWrite ("HKCR\.ref\ShellNew", "FileName", "REG_SZ", "Template.ref")

RegWrite ("HKCR\ReferenceFile", "", "REG_SZ", "Reference File")
RegWrite ("HKCR\ReferenceFile\DefaultIcon", "", "REG_EXPAND_SZ", "%SystemRoot%\system32\shscrap.dll")
RegWrite ("HKCR\ReferenceFile\Shell", "", "REG_SZ", "Run")
RegWrite ("HKCR\ReferenceFile\Shell\Edit", "", "REG_SZ", "Edit File")
RegWrite ("HKCR\ReferenceFile\Shell\Edit\Command", "", "REG_SZ", "notepad.exe %1")
RegWrite ("HKCR\ReferenceFile\Shell\Open", "", "REG_SZ", "Open File")
RegWrite ("HKCR\ReferenceFile\Shell\Open\Command", "", "REG_SZ", "notepad.exe %1")

;----- HKEY_CLASSES_ROOT ----->
;=============================>
;----- HKEY_CURRENT_USER ----->

RegWrite ("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.ref")
RegWrite ("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.ref\OpenWithList", "List", "REG_SZ", "notepad.exe")
RegWrite ("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.ref\OpenWithList", "MRUList", "REG_SZ", "List")
RegWrite ("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.ref\OpenWithProgids", "ReferenceFile", "REG_NONE")

;----- HKEY_CURRENT_USER ----->
;=============================>
;----- HKEY_LOCAL_MACHINE ---->

RegWrite ("HKLM\SOFTWARE\Classes\.ref", "", "REG_SZ", "ReferenceFile")
RegWrite ("HKLM\SOFTWARE\Classes\.ref", "PerceivedType", "REG_SZ", "Text")
RegWrite ("HKLM\SOFTWARE\Classes\.ref\PersistentHandler", "", "REG_SZ", "{5e941d80-bf96-11cd-b579-08002b30bfeb}")
RegWrite ("HKLM\SOFTWARE\Classes\.ref\ShellNew", "FileName", "REG_SZ", "Template.ref")

RegWrite ("HKLM\Software\Classes\ReferenceFile", "", "REG_SZ", "Reference File")
RegWrite ("HKLM\Software\Classes\ReferenceFile\DefaultIcon", "", "REG_EXPAND_SZ", "%SystemRoot%\system32\shscrap.dll")
RegWrite ("HKLM\Software\Classes\ReferenceFile\Shell", "", "REG_SZ", "Run")
RegWrite ("HKLM\Software\Classes\ReferenceFile\Shell\Edit", "", "REG_SZ", "Edit File")
RegWrite ("HKLM\Software\Classes\ReferenceFile\Shell\Edit\Command", "", "REG_SZ", "notepad.exe %1")
RegWrite ("HKLM\Software\Classes\ReferenceFile\Shell\Open", "", "REG_SZ", "Open File")
RegWrite ("HKLM\Software\Classes\ReferenceFile\Shell\Open\Command", "", "REG_SZ", "notepad.exe %1")

;----- HKEY_LOCAL_MACHINE ---->
;=============================>
;----- HKEY_USERS ------------>

RegWrite ("HKU\S-1-5-21-1957994488-1993962763-854245398-1003\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExt\.ref")
RegWrite ("HKU\S-1-5-21-1957994488-1993962763-854245398-1003\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.ref\OpenWithList", "List", "REG_SZ", "notepad.exe")
RegWrite ("HKU\S-1-5-21-1957994488-1993962763-854245398-1003\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.ref\OpenWithList", "MRUList", "REG_SZ", "List")
RegWrite ("HKU\S-1-5-21-1957994488-1993962763-854245398-1003\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.ref\OpenWithProgids", "ReferenceFile", "REG_NONE")

;----- HKEY_USERS ------------>

:whistle::dance:

Source code is attached to this post for easier access.

Source.au3

"... and the Lord said to John, "Come forth and ye shall receive eternal life," but instead John came fifth and won a toaster."

Link to comment
Share on other sites

Go through code and change ".ref" to whatever extension you like and you can register whatever enxtension you like.

how about formatting this code as a function, so the user enters the desired extension as a parameter.

also, to round out such a functionality, create a function that de-registers an extension

[u]Do more with pre-existing apps![/u]ANYGUIv2.8
Link to comment
Share on other sites

how about formatting this code as a function, so the user enters the desired extension as a parameter.

also, to round out such a functionality, create a function that de-registers an extension

<{POST_SNAPBACK}>

Ditto what he said.
FootbaG
Link to comment
Share on other sites

I think you're playing with something you don't understand and it's a very dangerous thing to be playing with. The way file extension associations are set up in the registry is quite simple and does follow a very distinct pattern. In fact, if you search the forum, you'll find examples of code for doing various things to file extension associations.

Link to comment
Share on other sites

I think you're playing with something you don't understand and it's a very dangerous thing to be playing with.  The way file extension associations are set up in the registry is quite simple and does follow a very distinct pattern.  In fact, if you search the forum, you'll find examples of code for doing various things to file extension associations.

<{POST_SNAPBACK}>

Yes I know it all follows a distinct pattern. I don't, however, want to give anyone just learning this language, and who has never programmed before, free reign to delete any key THEY feel they don't need.

I know that the default key in the extension's folder that you're looking at contains the the folder to point to for instructions on how to deal with that extension... and yes I know that I could use that key as a pointer to delete the folder if need be, but I want to create something a little safer. I don't want to give them access to just type in a random extension and have it deleted.

That's why I said I what I said. :whistle:

Edited by Frozenyam

"... and the Lord said to John, "Come forth and ye shall receive eternal life," but instead John came fifth and won a toaster."

Link to comment
Share on other sites

make it so the settings are temporary then, while the script is running.

<{POST_SNAPBACK}>

That's an ingenius idea! :whistle:

I could have it take the setting that you input and have it create a registry patch file. So when you're done executing the script all file extensions return to the way they were before you ran it. Hence it creates the keys only when you need them, and then removes them when you don't. That's the most brilliant idea I've read all day.

"... and the Lord said to John, "Come forth and ye shall receive eternal life," but instead John came fifth and won a toaster."

Link to comment
Share on other sites

And check if the keys already exists... Be like If RegRead or RegReag or RegRead or etc. Then Exit. So that way you don't write over previous keys. Or if someone actually WANTs to run over a previous key, make an optional paramter.

Good luck.

Oh yea, and like Valik said... Be careful. Because if I register an extension either manually or with AutoIt, I generally only use I think it's 3 keys. But if I need more detail I'll use a little more. But like some of the keys you used, I've never seen, so I wouldn't run it :whistle: Not because I don't trust you, it's because I don't know what those keys do :dance: Only a few of em' I know, that's why I only use a few :(:dance:

Edited by layer
FootbaG
Link to comment
Share on other sites

And check if the keys already exists... Be like If RegRead or RegReag or RegRead or etc. Then Exit. So that way you don't write over previous keys. Or if someone actually WANTs to run over a previous key, make an optional paramter.

Good luck.

Oh yea, and like Valik said... Be careful. Because if I register an extension either manually or with AutoIt, I generally only use I think it's 3 keys. But if I need more detail I'll use a little more. But like some of the keys you used, I've never seen, so I wouldn't run it :whistle: Not because I don't trust you, it's because I don't know what those keys do :dance: Only a few of em' I know, that's why I only use a few :(:dance:

<{POST_SNAPBACK}>

Most of the other keys are to add the file extension to the to a menu. Specifically the one when you right-click the desktop and go down to "New" it will put the new file type in that meny so that you can create a new one without opening notepad or something and then saving it with that extension. You might have to wait for these additions as classes for me resume tomorrow morning and most of my days will be booked with class/work until weekends. Edited by Frozenyam

"... and the Lord said to John, "Come forth and ye shall receive eternal life," but instead John came fifth and won a toaster."

Link to comment
Share on other sites

Be careful of reusing GUIDs also:

RegWrite ("HKCR\.ref\PersistentHandler", "", "REG_SZ", "{5e941d80-bf96-11cd-b579-08002b30bfeb}")
There are free GUID generators out there if you need a GUID for your app.

<{POST_SNAPBACK}>

That GUID isn't a problem, but thanks for the concern.

"... and the Lord said to John, "Come forth and ye shall receive eternal life," but instead John came fifth and won a toaster."

Link to comment
Share on other sites

Brings back good old days of playing with the system registry. I learned alot of CLSID, COMS, File Extensions, Configuration, etc.

"I only smile in the dark

My only comfort is the night gone black

I didnt accidentally tell you that

Im only happy when it rains"

Uh.... riiiiiiiiight....... ok.

Hold on a sec.

"Hello, is this doctor vanvincan? Id like to arrange an appointment for valik. See he has this uhm.... condition. He gets depressed very easily."

Edited by myredeemerlives
Link to comment
Share on other sites

That GUID isn't a problem, but thanks for the concern.

Right, my comment was more directed at people who copy this code and use it to register a hundred extensions of their own. I don't know what that particular GUID relates to, but I just wanted to make people aware that they should generate a new one if they plan on using this method to multiple purposes. Windows can become confused by duplicate GUIDs in the wrong place.

My UDFs: ExitCodes

Link to comment
Share on other sites

but I just wanted to make people aware that they should generate a new one if they plan on using this method to multiple purposes. 

You should not say that when you also say this:

I don't know what that particular GUID relates to,

The GUID you show an example of is a PersistentHandler. Your advice to generate a new one will break the functionality. The PersistentHandler must point to a valid interface identified by it's GUID or it will not work.
Link to comment
Share on other sites

I've looked at the feasability of making this code a function and have determined that there would just be far too many variables to reference.

- The extension to register

- The program to run/open/etc... the file with

- The icon to be used (optional)

- The persistent handler

- The reference folders cited in the default extension folder.

- And a few others.

It would just be far too much work for me.

So... if anyone wants to modify the code themselves, they can go right ahead and do so.

"... and the Lord said to John, "Come forth and ye shall receive eternal life," but instead John came fifth and won a toaster."

Link to comment
Share on other sites

You should not say that when you also say this:

The GUID you show an example of is a PersistentHandler.  Your advice to generate a new one will break the functionality.  The PersistentHandler must point to a valid interface identified by it's GUID or it will not work.

I'm sure you're right. I obviously haven't scripted anything that uses Windows GUIDs before, but after searching the registry I see that that GUID points many files to the Plain Text persistent handler, so yeah, you'd have to reference it to take advantage of what that handler has to offer.

Where I do have experience with GUIDs is in installer software programs. They will typically generate a GUID for your program so that it doesnt' interfere with the functionality of any pre-existing GUIDs. This obviously is not what this script is doing, so please disregard my previous comments.

Good day. :whistle:

My UDFs: ExitCodes

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...