topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Friday December 13, 2024, 10:49 pm
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: SOLVED: Redirect clicks on files of a particular type to a *specific* single file?  (Read 8393 times)

JavaJones

  • Review 2.0 Designer
  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 2,739
    • View Profile
    • Donate to Member
I must now call upon the great DonationCoder wizards to help me pull off a birthday present for my girlfriend. :D

Quick version: I need a little utility that runs resident and lets me redirect clicks (or any "open" commands in the file manager) for *any* file of specific types (multiple types) to *one* specific file. In other words if someone clicks on bob.avi, john.mkv, or jo.mp4, I could redirect all of those to me.mov. I imagine doing it by setting file extension wildcards on a redirect list, e.g. "*.mkv, *.avi, *.mp4", etc. and then a field to set the file to redirect to. Also note: this need to work on Win 7.

Some background for why I need this: for the last several years my friends and I have made a tribute video to my girlfriend which we premiere at her birthday, generally to her surprise. This will be our 3rd video, so she's probably expecting it by now, and we want to try to keep it surprising. One of the dead giveaways is the big reveal moment, "hey, let's put a video on", but on this particular night we know she plans to watch some movies anyway. So my idea is to let her pick from the list of movie files on the computer, and she needs to be able to pick *any* movie so it's not obvious that we're rigging it, and then whatever she picks it actually opens the movie we have made.

Now the idea could be made broader, using complex naming wildcards or whatnot (i.e. more than just *). All I need is to match the file extension, but a more flexible tool would be more likely to have use for others.

And this does have possible functional use, albeit arguable. Let's say you have a computer that you let your kids use and you don't want to allow them to open and/or mess with important files, like system files (yes, protectable via "hide system files" in large part, but that's less convenient and selective). So you add *.SYS, *.DAT, etc. to the filter and turn the app on when you let them on the computer. If they try to open any of those files you can redirect to an app or word doc that says "sorry, you shouldn't be opening this" or whatever. Maybe protect the disable/exit of the app with a password. There are certainly other possible uses too...

Forgive me if this has already been done, or if the way to do it is obvious. All solutions and related info are appreciated.

- Oshyan

argv

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 45
    • View Profile
    • Donate to Member
In this specific case it might be easier to replace the executable of the registered media player with some batch which will always run the same movie. Or to use image hijacking; take a look at "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options"

f0dder

  • Charter Honorary Member
  • Joined in 2005
  • ***
  • Posts: 9,153
  • [Well, THAT escalated quickly!]
    • View Profile
    • f0dder's place
    • Read more about this member.
    • Donate to Member
IMHO the best route is simply redirecting the file extension(s) wanted to an app of your choice (keeping a reference to the old association, so you can uninstall later). This gets your app invoked when a file of the type is ShellExecute()'d; the simple version could simple run your hardcoded .mov with the old media player (either by hardcoding, or by "emulating" ShellExecute and parsing the old filetype association). More advanced version would would parse commandline, and take action depending on some config file.

If "Image File Execution Options" simply hijacks "mediaplayer.exe -> myhandler.exe", aren't you going to get into an infinite loop when "myhandler.exe" tries to use "mediaplayer.exe" to redirect *.mov -> "myfile.mov"? :)
- carpe noctem

argv

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 45
    • View Profile
    • Donate to Member
If "Image File Execution Options" simply hijacks "mediaplayer.exe -> myhandler.exe", aren't you going to get into an infinite loop when "myhandler.exe" tries to use "mediaplayer.exe" to redirect *.mov -> "myfile.mov"? :)

Good question :)

Shades

  • Member
  • Joined in 2006
  • **
  • Posts: 2,939
    • View Profile
    • Donate to Member
Are there not some (portable) applications that manage extensions? That method would beat changing all extensions in registry and restoring them after-wards. IMHO nobody should be playing too much with the registry, especially when it isn't (absolutely) necessary. The suggested registry changes are easy enough to change, but still...

Here is a link to a freeware portable extension manager (actually: a program launcher) that might be doing all that you need.

Edit:
found a link to a DC thread about Portable Extension Manager (PEM) as well
« Last Edit: January 24, 2010, 09:46 AM by Shades »

Stoic Joker

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 6,649
    • View Profile
    • Donate to Member
IMHO nobody should be playing too much with the registry, especially when it isn't (absolutely) necessary. The suggested registry changes are easy enough to change, but still...
I gota go with Shades on this, the whole risk/reward thing is skewed toward the danger zone if the unwind doesn't-go-as-planed...

Why not go with a tactic that offers less exposure, like changing the preferred media players normally used shortcut (a single point) to target the desired video. ...Sure it may require some fast talking to pull off, but it's a hell of a lot easier to "fix" after the joke is played.

argv

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 45
    • View Profile
    • Donate to Member
I had some time so I tried the redirection using "Image File Execution Options" It seems to work pretty well, you have to create a copy of the wmplayer.exe binary with a different name (I have used xwmplayer.exe) and then to use this second name for the hijacked exe. It works with both wmplayer and vlc..

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\wmplayer.exe]
"Debugger"="\"C:\\Program Files\\Windows Media Player\\xwmplayer.exe\" C:\\sample.mpg"


JavaJones

  • Review 2.0 Designer
  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 2,739
    • View Profile
    • Donate to Member
Thanks for all the responses guys, sorry for my late reply. What I ended up doing was making a simple .bat file that called my media player and passed the file name I needed in an argument. Then I re-associated the relevant media files to open with the .bat file, and viola! A bit messy as it does pop up a commandline window briefly, but the results were (or would have been) effective. Unfortunately the movie wasn't ready in time, but it will be for Valentine's Day soon... :D

Thanks again!

- Oshyan