Jump to content

Registering Extensions/Associations - two methods


Dobby

Recommended Posts

I just did a search for File Extensions and did not get the following page listed in the results:

Registering File Extensions Unattended (Fortunately, I had it in my history so I was able to get the link).

Anyway, I was looking at this post and comparing it with the alternative method:

Gosh's Unattended Tips And Tricks: Trick #3: Associate file types

To me, using the ASSOC command and FTYPE seems to be a cleaner way of doing it than lots of registry stuff.

I'd like to know ppls opinions on this. Is there a prefered method?

Link to comment
Share on other sites


One thing you have to know, is the "assoc" command will work only for registered programs. So if you already have registered apps, associating the extensions is TEN TIMES easier (and better) to do via assoc.

If you are starting from a situation where you KNOW that your app doesn't already have any entries in the registry, and its YOU who has to do it all, then the .REG method is good.

Link to comment
Share on other sites

Could you clarify 'registered' program?

As a test I took my favorite editor (EditPlus) and copied it to my Clean VPC install.

I then did the following:

C:\>ftype editplus=c:\editplus\editplus.exe %1 %*
editplus=c:\editplus\editplus.exe %1 %*

C:\>assoc .txt=editplus
.txt=editplus

I then double-clicked a txt file and viola! it loaded EditPlus with the txt file. Have I missed something? Icons maybe?

Link to comment
Share on other sites

C:\>ftype editplus=c:\editplus\editplus.exe %1 %*

editplus=c:\editplus\editplus.exe %1 %*

Yep, that was sort of what I meant by "registered".

If you are comfortable with batch-files, it is far easier to do it that way. Dump the .reg way. :P:lol:

Oh, and its a good idea to NOT use absolute paths. Always use system variables. For example,

ftype editplus=c:\editplus\editplus.exe %1 %*   ---->  is not good

ftype editplus=%systemroot%\editplus\editplus.exe %1 %*  ---> is good

Also, if you are able to use this method itself for all associating all your extensions, then announce your findings in the "Registering File Extensions Unattended (REG)" thread. Probably they might be interested to move over to a less-complex method.

Link to comment
Share on other sites

what @prathapml tried to say is that you can't associate the file extension with a value that doesn't exist. that means that program need to be already installed and the value that you associate with the extension HAVE to exist.

Link to comment
Share on other sites

Oh, and its a good idea to NOT use absolute paths. Always use system variables.

Oh of course it was only an example my scripts never have absolute paths in. Sorry I should follow the rules ALL the time. Call myself a programmer. Pah! Slap those wrists :)

Link to comment
Share on other sites

Well, thanks guys for the info. I don't see any reason why the extensions can't be applied after the relevant application is installed and personally I think it's a neater way to apply the associations. What's really nice is that these commands by themselves (without any parameters) list all the associations which is much easier to read than the registry.

I'll make any issues I come across known. Thanks again.

Link to comment
Share on other sites

I used to do the assoc/ftype way of doing things. I've since moved to an inf to add registry keys. Only reason is that it provides much more power in what I can do. Such as changing icons, adding menu extensions for certain file types, etc. If you are JUST looking for a quick and dirty way to associate extensions do the assoc way, but when you need to do more stuff with them, go the registry way.

Link to comment
Share on other sites

  • 4 months later...

I am associting the files using a batch file. Can someone please guide me what is the error in my bat file, because the files with long names (or spaces) do not open, especially in vlc player?

assoc .dat=VCDMovie  
ftype VCDMovie="%programfiles%\vlc\vlc.exe" %%1 %%*

Like a file "c:\Music\My videos\my saved video.dat" doesn't open in VLC, but a file without name space can be opened.

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
  • Recently Browsing   0 members

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