Making a file (bat?) to automatically create files associations?


  1. Posts : 289
    Win7x64
       #1

    Making a file (bat?) to automatically create files associations?


    Hello, currently if i want to had a file extension to Windows, i have to open the new file type, select the app & tick "always open with" then go to the "Types" app to select correct icon.

    This take times, especially if doing it on many computers. So is it possible with a .bat/cmd file to create these extension AND make them display the correct/unbroken icon?
      My Computer


  2. Posts : 5,656
    Windows 7 Ultimate x64 SP1
       #2

    Would something like this accomplish what you want? Edit File Type Association, Actions & Icon From Right-Click Menu
      My Computer


  3. Posts : 289
    Win7x64
    Thread Starter
       #3

    ... If you read my message (not just the title), you'll see i mention this exact app which i use already. So i look for something else obviously. Thanks for taking time to reply though.
      My Computer


  4. Posts : 5,656
    Windows 7 Ultimate x64 SP1
       #4

    Oh, sorry

    Something like this? batch - Programatically associate file extensions with application on Windows - Super User

    Example used in Answer in above link:
    Code:
    Assoc .php=phpfile
    Ftype phpfile="C:\Program Files (x86)\Notepad++\notepad++.exe" %1
      My Computer


  5. Posts : 289
    Win7x64
    Thread Starter
       #5

    It looks good but didn't work for me! It would set the right icon anyway.. Here's what i tried :

    Assoc .gp4=gp4file
    Ftype .gp4=gp4file="D:\Apps\GuitarPro5Portable\GuitarPro5Portable.exe" %1
    You may think pointing to portable apps doesn't work but it does when i do manually.
      My Computer


  6. Posts : 5,656
    Windows 7 Ultimate x64 SP1
       #6

    Code:
    Assoc .gp4=gp4file
     Ftype (.gp4=)gp4file="D:\Apps\GuitarPro5Portable\GuitarPro5Portable.exe" %1
    The bold part is incorrect, does it work if you delete that bit? Or a typo?

    See
    Code:
    Assoc .gp4=gp4file
    Ftype gp4file="D:\Apps\GuitarPro5Portable\GuitarPro5Portable.exe" %1
    edit: bold is hard to see, I put parenthesis around it too
      My Computer


  7. Posts : 289
    Win7x64
    Thread Starter
       #7

    It works indeed, thanks! However as i said, it doesn't fix the icon correctly
      My Computer


  8. Posts : 5,656
    Windows 7 Ultimate x64 SP1
       #8

    See if this works better (taken from windows - Associate a File Type with a Specific Program - Super User)

    Save as .bat file
    Code:
    set ftypename=potato_xxx_file
    set extension=.potato
    set pathtoexe="C:\potato.exe"
    set pathtoicon=""
    
    if %pathtoicon%=="" set pathtoicon=%pathtoexe%,0
    REG ADD HKEY_CLASSES_ROOT\%extension%\ /t REG_SZ /d %ftypename% /f
    REG ADD HKLM\SOFTWARE\Classes\%ftypename%\DefaultIcon\ /t REG_SZ /d %pathtoicon% /f
    ftype %ftypename%=%pathtoexe% "%%1" %%*
    assoc %extension%=%ftypename%
    Some hints:

    ftypename - FileType name can be random but should be unique.

    extension - A filename extension. Examples of filename extensions are .png, .jpeg, .exe, .dmg

    pathtoexe - Full executable path.

    pathtoicon - Full path to icon or executable file with selected icon. If icon path empty then default icon from exe will be used. If want use custom icon change set pathtoicon="" for example to set pathtoicon="C:\icons\potato.ico".

    Works atleast in Windows 7.
      My Computer


  9. Posts : 289
    Win7x64
    Thread Starter
       #9

    Yes it works, thank you! Now i gotta make a list of all the needed extensions.. ^^
      My Computer


  10. Posts : 5,656
    Windows 7 Ultimate x64 SP1
       #10

    Nice :)
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 01:57.
Find Us