Link to home
Start Free TrialLog in
Avatar of Joe
JoeFlag for United States of America

asked on

Change File Association Remotely

Hello all, is this possible to do??? If this is how can I do this?? Thanks Guys. What I need to do is set all users in the office to use another program to open TIFF files than what that extension is currently associated with right now.

Thanks,

Joe
Avatar of sramesh2k
sramesh2k
Flag of India image

Joe,

See if this example helps.

How to associate an image file with IrfanView, using command-line in Windows XP?:
http://windowsxp.mvps.org/imgasso.htm

You could create a startup script for the same so that the settings are applied for all the systems in the network.
Avatar of Joe

ASKER

Nice! thanks! That is exactly what we are looking to do, and that is the exact program I need to change the file association to Irfanview. Now do you know if this would work with a windows 2000 machine also??? We have a mixed environment of 2000 and XP machines with the majority XP, if it doesnt this should not be too much of a problem since most of our 2000 machines have been updated. Thanks!

Joe
Avatar of AmigoJack
AmigoJack

are you familiar with the registry editor? if yes, open it. if no, go beyond ======

go to the key "HKEY_CLASSES_ROOT\.tif" and see which value "(Standard)" has. remember the value

go to the key "HKEY_CLASSES_ROOT\*TheValueFromAboveYouHadToRemember*
on "(Standard)" you can change the description which should appear in the explorer for this file extension.
go to the subkey "shell", then "open" then "command". under "(Standard)" you just have to enter the full path including the executable of irfanview. this must be enclosed by " and then followed by a whitespace and "%1" including " so it could look like this:

"C:\Program Files\IrfanView\IrfanView.exe" "%1"

thats it. purely you can create a file like the following one (without the ----- but all lines between, also empty lines):

---------
REGEDIT4

[HKEY_CLASSES_ROOT\.tiff]
"Content Type"="image/tiff"
@="MY___BOGUS"

[HKEY_CLASSES_ROOT\.tif]
"Content Type"="image/tiff"
@="MY___BOGUS"

[HKEY_CLASSES_ROOT\MY___BOGUS]
@="My cool description for TIFF-files"

[HKEY_CLASSES_ROOT\MY___BOGUS\DefaultIcon]
@="C:\\PROGRA~1\\GEMEIN~1\\MICROS~1\\MSPaper\\MSPVIEW.EXE,1"

[HKEY_CLASSES_ROOT\MY___BOGUS\shell]
@="Open"

[HKEY_CLASSES_ROOT\MY___BOGUS\shell\open]

[HKEY_CLASSES_ROOT\MY___BOGUS\shell\open\command]
@="\"C:\\PROGRA~1\\GEMEIN~1\\MICROS~1\\MSPaper\\MSPVIEW.EXE\" \"%1\""

-------
please note that "MY___BOGUS" can be any name your can freely choose. irfanview will also make its own name decision on there. also note the line with "...\DefaultIcon": here you either point directly to some .ICO file which should be displayed as icon for every TIFF-file, or you use (like most times) an icon inside of a program, like irfanview itself. simply pass the full path + exename and then a comma and a number, beginning from 0. 0 will mostly be the icon you see from the executable itself, but it may contain others as well, so you can try them all by incrementing the number. (modifying a link to a executable gives you a dialog where you can also customize the icon - simply choose your irfanview.exe and youll see all the icons it contains - then remember the position of the icon you wish and you got it :)

ok, this seems massive, but its also simple in the end :P

=========
not knowing the registry isnt good for using it. but let me just answer: yes, it works on every machine. this whole file association thing is still the same from the beginning of win95 and has never changed. it works for 95, 98, 98SE, ME, NT3.51, NT4, 2K, XP, 2003 and also all RCs :)
Joe,

Assoc and ftype should work fine in Windows 2000 as well. Also, the two commands are refenced in these two MS links:

http://www.microsoft.com/technet/archive/winntas/deploy/shellscr.mspx
http://www.microsoft.com/technet/prodtechnol/Windows2000serv/support/FAQW2KCP.mspx

Hope that helps.
Avatar of Joe

ASKER

sramesh2k ,

I have put this in a .bat file

ASSOC .JPG=IView
ASSOC .TIF=IView
FTYPE IView="%Programfiles%\IrfanView\i_view32.exe" %1

I have ran this on my machine and it seems to change the file addociation of .tif to Irfanview. Now my only problem is when I try and double click the file to open it it says no file loaded. But if I go to file open within Irfanview it seems to open the file ok.


AmigoJack,

I have looked at this script but have not tested it yet. I am getting a machine ready now to try it out. I am not too familiar with those commands so bear with me.

Thanks Guys,

Joe
Joe,

See if changing the line:

FTYPE IView="%Programfiles%\IrfanView\i_view32.exe" %1

to

FTYPE IView="%Programfiles%\IrfanView\i_view32.exe" "%1"

(Only difference is that the quotes are added for the file name)
ASKER CERTIFIED SOLUTION
Avatar of sramesh2k
sramesh2k
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Joe

ASKER

sramesh2k,

I have changed the file associations back to the windows image viewer and copied the above and put it in the .bat file. When I ran it that seemed to not do anything is this because I already ran the script before???? Maybe this script can only be run one time on a computer to change the file association? Thanks.

Joe
Joe,

It works fine here. Have you tried opening a JPG file now, after running the batch file?
Avatar of Joe

ASKER

sramesh2k ,

After I run it and open the JPG it still is associated with the windows picture and fax viewer. Its weird. For some reason I think if you change the file association again manually then try and run the script for some reason it wont re-change it. Any suggestions?

Thanks,

Joe
Joe,

Add a line with the command named PAUSE to see what's happening when you run the batch file.

- - -
ASSOC .JPG=IView
FTYPE IView="%Programfiles%\IrfanView\i_view32.exe" "%%1"
pause
- - -

You'll see the error message (if any) in the prompt.
Avatar of Joe

ASKER

Interesting this does not seem to pull up an errors. It seems like it is running the file ok. It just says press any key to continue. I am thinking this could be a windows problem. I am going to try that line of code on another computer with Irfanview. Thanks.

Joe
Avatar of Joe

ASKER

sramesh2k ,

I have tested this on another machine and it seemd to work perfectly! The problem seems to be when you run the script and change the file extension then manually change the file extension to somehting else then run the script again and this seems to make it not work. I think this should be sufficient enough though unless you know of any ways of getting around that. Thank you for all of your help!

Joe
Good luck, Joe and keep us posted. In case of any problems, we'll look for other alternatives.