8

I have a usb stick with PortableApps that I carry around between different places.

But one thing that annoys me, is when I open a file (such as *.flv or *.html), either Windows says it is unsupported or it opens a program that I do not want to use (eg Win.M.P.), while I have the "correct" program (that I want to use) on my USB drive.

Is there any portable program that can associate my "unsupported" files when I execute just one/a few program/s?

(I was about to use ftype and assoc on a batch file, but it requires administrator privileges, so that doesn't seem to be the best solution.)

0

6 Answers 6

6
+50

I use a lot of portable apps, and I use two programs especially made for this. They both do the same thing, but in different ways.

eXpresso (made using AutoHotkey) intercepts mouse clicks and changes the action to open whichever program that you associate the file type with.

Portable File Associator (made using AutoIt) makes file association entries in the HKCU registry hive, which does not need admin rights, and it can be set to remove them when the program is exited. I prefer this one, as it can also be made to make the entries and then exit without removing the associations, which is useful on my own computers (the instructions for more advanced use are in a file somewhere in the program folder). The way it works also allows you to define icons to the file types. When you download this program, the password for the archive file is in the file name.

Programs made using AutoIt and AutoHotkey can sometimes get flagged as viruses by anti-virus programs, as viruses have been made using them, but these programs are totally safe.

3
5

Here is what I use, which might be overcomplicated:

  • Have a batch file on the USB drive that maps its folder to the Q: or another drive letter (subst Q: "%~dp0" basically)
  • Use a portable explorer with custom file associations. I use FreeCommander; under “Extras, Preferences, Programs” you can set custom programs to open when hitting F4 on your files, depending on their extension. I have mapped 7z,zip,tar,etc. to 7zip-portable for example. So all you have to do is set the editor to Q:\7z-portable\7zportable.exe and that's all.
4
  • Adding +1 for good answer. But is it possible to do it in a simpler way? Or can you explain your answer in more detail of how/why map the folder to `Q:` or another drive?
    – auroranil
    Feb 3, 2012 at 11:24
  • 2
    @user824294 I would assume this allows him to keep his associations static. They always go to Q:\myprogram.exe instead of different_every_time:\myprogram.exe Feb 4, 2012 at 0:17
  • @Oliver Salzburg: I couldn't say it better.
    – Benoit
    Feb 13, 2012 at 8:26
  • This is unnecessary, you can specify custom file associations in FreeCommander using relative paths to the Freecommander executable, that means they are totally resilient to drive letter changes. You don't need the batch file shenanigans at all. Jul 25, 2017 at 23:35
3

You can use the standard assoc command in a batch script (.bat) to save, set and reset file associations.

The assoc command can display and association, for example, in a Command Prompt (cmd) :

image1

The command can also set a file-association :

image2

You can create the following two .bat files on the root folder on the USB disk (or elsewhere). These batch files require the presence in the same folder of a file named prefix that you create only once using notepad and typing the string "assoc ", without the quotes and with the ending blank and (very important) without pressing Enter (so it doesn't have an end-of-line).

The first .bat file we will call myapps.bat, and whose purpose will be to assign the new file association, after creating another restore.bat file that you will use before ejecting the USB disk in order to restore the old file associations.

An example myapps.bat to set the file associations of html, abab and htm to myprog1.exe etc. :

@echo off
echo @echo off >restore.bat
cmd /q /c doassoc html "%cd%\myprog1.exe"
cmd /q /c doassoc abab "%cd%\myprog2.exe"
cmd /q /c doassoc htm "%cd%\myprog3.exe"
del ftemp1
del ftemp

The variable %cd% stands for the current directory, but you can also use %cd:~0,2% which will give you the current disk (for example G:) together with any other relative file specification on the disk.

The doassoc.bat file which does the work for one file association will contain :

echo assoc .%1= >ftemp1
assoc .%1 >nul
IF %ERRORLEVEL% NEQ 0 goto notfound
assoc .%1 >ftemp
copy /b /y prefix+ftemp ftemp1 >nul
:notfound
copy /b /y restore.bat+ftemp1 restore.bat >nul
assoc .%1=%2

An example of the result when running myapps.bat followed by restore.bat is :

image3

3
  • 1
    Awesome. But could you verify that it does not require admin privileges? +50 if it does not.
    – auroranil
    Feb 4, 2012 at 2:18
  • Sorry, I was testing this with UAC disabled. assoc does require admin rights.
    – harrymc
    Feb 5, 2012 at 8:54
  • I would delete this, except that it may still be useful for somebody. Don't bother to undervote.
    – harrymc
    Feb 5, 2012 at 10:09
3

I assume you are using software packaged by PortableApps.com. While we are waiting for file associations to be implemented, Xenon Portable may be the easiest solution.

You can use the GUI to manage file associations...

settings

editor

or you can edit the XenonPortable\Data\settings\assoc.ini configuration file.

The format is as follows:

[<extension>]
icon=<image>.ico
exe=|XEDIR|\<path>

Where <path> is relative to the XenonPortable directory.

2

You could use the XYplorer portable file manager. Its latest version is commercial, but the last freeware version is still available from here.

Its Portable File Associations can associate file extensions with applications and even with user-written scripts :

image

0
1

As mentioned by paradroid, previously you could used apps like the (now defunct) eXpresso or PortableFileAssociator to solve this issue. Unfortunately, as of Windows 8, it is no longer possible to temporarily set file associations.

As explained by John T. Haller - Creator of PortableApps.com

Windows 8, 8.1, and 10 don't permit apps to adjust file associations and then set them back anymore the way we had planned when developing for Windows XP/Vista/7. Associations must go through the OS with the user being prompted to change them. This is by design so that apps can't steal associations like setting themselves as your default browser without your permission.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .