You are here

Portable Filetypes?

11 posts / 0 new
Last post
dyce
Offline
Last seen: 15 years 4 months ago
Joined: 2006-04-10 23:12
Portable Filetypes?

can someone make an app that sets which files are opened with what on the portable usb? like i have photoshop, and i want to open some image file, but first of all, after plugging in my usb, i run the filetype thing and then just click on the file and it opens with the photoshop on my usb drive. then before ejecting, it resets the filetypes back to default. this could come in handy.

Bruce Pascoe
Offline
Last seen: 10 years 11 months ago
Joined: 2006-01-15 16:14
...

This is not portable, nor is there really a way to make it so.

[1.]
The local registry has to be modified for this to work. Even if there was a portable registry, you couldn't utilize it, since Windows invariably uses the local registry for file associations.

[2.]
There's no way to have an app on the drive automatically run before unmounting it, and Windows doesn't touch the Open= line in autorun.inf, so you'll have to launch the association and unassociation processes yourself. Plus, if you forget to run the unassociation process before ejecting the drive, those file types will remain associated with the apps on your USB drive instead of the local apps. This is not good for the user of the host machine, especially if they don't know what they're doing.

[3.]
Write access to HKEY_CLASSES_ROOT (the registry key where file associations are stored) requires at least Power User privileges (possibly even Administrator privileges) under Windows 2000 and XP. True portability requires that an application run unhindered even with Guest privileges.

Sorry to crush your hopes and dreams, ~Strong Bad

Torpedro
Offline
Last seen: 9 years 2 months ago
Joined: 2006-02-05 14:52
reg-wrapper for file extension

I know it's against the portability rules,

You can just use a reg-wrapper to do this (IF you have permisson on the OS) to backup, import, and export the needed keys.
would be enough to change HKCR\.[extension] and use your own handlers like HKCR\[extensionHandler.MyUSBdrive].
And you don't need to change the default action (double click), but just can add a "MyUSB" entry to contextmenu. Could be done on XP with reg.exe and a batch script easily.
Consider letting a temp-batch run to auto delete all your settings after a specific time e.g. 2 hours (can be hidden with cmdow.exe).

Example:
--------- Begin LOCAL -------------
REGEDIT4

[HKEY_CLASSES_ROOT\.7z]
@="7-Zip.7z"

[HKEY_CLASSES_ROOT\7-Zip.7z]
@="7z Archive"

[HKEY_CLASSES_ROOT\7-Zip.7z\DefaultIcon]
@="D:\\Programs\\FileManagement\\7-Zip\\Formats\\7z.dll"

[HKEY_CLASSES_ROOT\7-Zip.7z\shell]
@=""

[HKEY_CLASSES_ROOT\7-Zip.7z\shell\open]
@=""

[HKEY_CLASSES_ROOT\7-Zip.7z\shell\open\command]
@="\"D:\\Programs\\FileManagement\\7-Zip\\7zFMn.exe\" \"%1\""

--------- End LOCAL -------------

Note the MyUSB and changed path. The original HKEY_CLASSES_ROOT\7-Zip.7z will not be modified. You then have a context menu entry "MyUSB"
--------- Begin USB -------------
REGEDIT4

[HKEY_CLASSES_ROOT\.7z]
"MyUSB"="7-Zip.7z.MyUSB"
@="7-Zip.7z"

[HKEY_CLASSES_ROOT\7-Zip.7z.MyUSB]
@="7z Archive"

[HKEY_CLASSES_ROOT\7-Zip.7z.MyUSB\DefaultIcon]
@="Y:\\PortableApps\\7-Zip\\Formats\\7z.dll"

[HKEY_CLASSES_ROOT\7-Zip.7z.MyUSB\shell]
@=""

[HKEY_CLASSES_ROOT\7-Zip.7z.MyUSB\shell\open]
@=""

[HKEY_CLASSES_ROOT\7-Zip.7z.MyUSB\shell\open\command]
@="\"Y:\\PortableApps\\7-Zip\\7zFMn.exe\" \"%1\""
--------- End USB -------------
to delete you would just delete:
HKEY_CLASSES_ROOT\.7z\MyUSB="7-Zip.7z.MyUSB"
--------- Begin CLEAN.bat -------------
reg.exe delete HKCR\.7z /v MyUSB
--------- Begin CLEAN.bat -------------

HKEY_CLASSES_ROOT\7-Zip.7z.MyUSB

--------- Begin CLEAN.reg -------------
REGEDIT4

[-HKEY_CLASSES_ROOT\7-Zip.7z.MyUSB]

--------- End CLEAN.reg -------------

Of course the later can be done with reg.exe also, just a litte example how to del a complete key (reg.exe /? for help)

I only use batch files, but if you need one, i could try. You would need external tools on you usbdrive for the batch to be clean.

Bruce Pascoe
Offline
Last seen: 10 years 11 months ago
Joined: 2006-01-15 16:14
...

You still have the issue of what happens if you forget to unregister the filetypes before ejecting (I tend to forget things like this myself), as there's no way to autorun something before-eject. I'm not so sure the user of the host machine would be too happy about his associations pointing to nonexistant apps after someone used his computer.

Torpedro
Offline
Last seen: 9 years 2 months ago
Joined: 2006-02-05 14:52
CleanReg.bat

Thats why i wrote a small sample CleanReg.bat
You copy the batch file to %temp% and run it from there:

rem --------- Begin starting CleanReg.bat -------------
copy CleanReg.bat %temp%\*.*
cd /d %tmep%
call %temp%\CleanReg.bat
rem --------- End starting CleanReg.bat -------------

You need any sleep utility (there is a workaround with "ping @ping 127.0.0.1 -n 30 -w 1000 > nul" there 30 would be the sleep time in seconds).
cmdow.exe is needed to hide the cmd-window.
The last line deletes the batchfile, remove rem after testing.
rem --------- Begin CleanReg.bat -------------
set RunID=CleanReg_%time%
title {%RunID%}
for /f "tokens=1-5" %%a in ('cmdow /t /b^|find "{%RunID%}"') do (set cmdow_Handle=%%a&set cmdow_PID=%%c)
cmdow "%cmdow_Handle%" /HID

:Loop
if exist "%pdrive%\System\sleep.exe" (sleep 30 &goto Loop)

:RedoAllRegChanges

pause
rem del %0
rem --------- End CleanReg.bat -------------

Deuce
Offline
Last seen: 12 years 2 months ago
Developer
Joined: 2005-12-24 16:32
I agree with Bruce...

As this can be a very usefull thing, it is never can be foolproof. Because of two things:

1. You cannot always gurantee that the user is on a machine that allows registry writes to HKCR.

2. The user themselves may not remember to deregister. Not good for the owner of the pc.

I have been thinking about this, and have found many ways to add things to the registry, but the two problems above always stop me from implementing it. Because the program or app launcher would appear to be broken because of #1 and it would fail. Not good for me or those using it.

It can be done, just the above two problems will always be there.

***********************************
Deuce {The Core}
"Portable Software: Just the beginning.

Deuce
Portable Software: Just the beginning.

Ashes for Tears
Offline
Last seen: 15 years 1 month ago
Joined: 2006-01-11 08:41
I know these questions might

I know these questions might sound terribly niave, but what about (just a theory) a more complex search algorithim like that in Registry Rapper? Mabey a Registry Rapper on 'roids. Using some sort of call system when certain programs or (is this even possibe?) programs under a certain directory level need to be executed. As for removal, mabey a system tray icon, or, perhaps it can be modified to perform an action when the 'Safely Remove Hardware' function is called, or even something as simple as a halt to the operation of removing the drive, or shutting down the proggie and a warning/reminder to restore associations...Anyway this is just speculation (I love a challenge :P).

I fully agree that there is a serious potential for problems, especially if something happens to crash. And, besides, messing with the registry is not always a good idea anyway; you really have to know what you're doing. :/

Bruce Pascoe
Offline
Last seen: 10 years 11 months ago
Joined: 2006-01-15 16:14
You keep misspelling that word...

It's "maybe", not "mabey". You have the Y in the wrong place. Smile

-
fatcerberus@yahoo.com  [aim: fatcerberus]
Somebody must be feeding Cerberus too much dog food again. Not that he doesn't know better than to eat it all... I say it's high time that beast went on a diet! And not the "see-food" kind...

Ashes for Tears
Offline
Last seen: 15 years 1 month ago
Joined: 2006-01-11 08:41
lol, ok, I'll make sure I

lol, ok, I'll make sure I spell it that way from now on...maybe! Wink Blum

tjorsch
Offline
Last seen: 15 years 4 months ago
Joined: 2006-08-20 10:37
Portable File Associations

The latest Beta of the file manager XYplorer (www.xyplorer.com) includes the ability to create file associations independent of the Windows registry. It allows you to map file types to applications on your portable device without having to specify a drive letter. Here is a description (XYwiki/File_Associations)

I have been using it and it really works well. The program has lots of other nice features too but It's shareware - $37.95 for a lifetime license. If you're interested in a File Manager replacement it's definitely worth a look.

Tim

Bahamut
Bahamut's picture
Offline
Last seen: 11 years 5 days ago
Joined: 2006-04-07 08:44
Would a shell replacement

Would a shell replacement that doesn't use the registry be able to do the same thing?

Vintage!

Topic locked