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) :
The command can also set a file-association :
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 @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"
%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
copy /b /y restore.bat+ftemp1 restore.bat >nul
An example of the result when running myapps.bat followed by restore.bat is :