File Extension Reassigner

Submit portable freeware that you find here. It helps if you include information like description, extraction instruction, Unicode support, whether it writes to the registry, and so on.
Post Reply
Message
Author
User avatar
lococobra
Posts: 127
Joined: Fri Aug 03, 2007 10:42 am
Location: USA
Contact:

File Extension Reassigner

#1 Post by lococobra »

Portable Shell Extension Reassigner ALPHA.V.0.2
By Lococobra

DISCLAMER: THIS PROGRAM IS STILL UNDER DEVELOPMENT!!! I make ABSOLUTELY NO guaruntee that this program will not completely destroy your computer!!!

I've done my best to insure that it runs reliably and settings are always recoverable, but there are sure to be problems I haven't forseen! I recommend testing this program on a virtual or frozen machine before using it on a computer you care about. The source code is availible with the program, if you find a bug and come up with a solution, please send me an email!


This program will read settings.txt and reassign any shell extensions you specify to an alternate program.

The settings format is:
.ext=path/to/program

For the path, you can use %pdrive% to specify the drive the script is running off of.

Example:
.jpg=%pdrive%/PortableApps/Pictureviewer/Viewer.exe

Any line in the settings file that doesn't begin with "." will be treated as a comment.


Good luck,
Lococobra

Comment at: portable.lococobra.com
Or email at: portable@lococobra.com

XPect
Posts: 36
Joined: Tue Feb 07, 2006 4:38 am
Location: France

#2 Post by XPect »

Quite good, but for the moment I prefer Cafe that do the same without touching the registry.

Now if you can handle icons replacement for file types in the same time it could be very good. I mean store the icons on the key and replace the association with file extension in the registry just while the key is present.

Regards

User avatar
lococobra
Posts: 127
Joined: Fri Aug 03, 2007 10:42 am
Location: USA
Contact:

#3 Post by lococobra »

I'm assuming you are talking about Property Cafe? It doesn't look to me like Cafe can change file extension assignments at all.

About icons, it already does that to some degree. When it overwrites the old registry keys, it overwrites the default icon as well. Only problem is, windows caches icons, so since my program is meant to be used portably, chances are you will never actually see the new icon take effect before you remove the drive.

By the way... I hope you guys are taking my warnings to heart about not using this on your actual computer... This alpha release is still very volatile. I'll be coming out with a new version soon.

Banshee
Posts: 15
Joined: Thu Jan 25, 2007 2:20 am

#4 Post by Banshee »

lococobra wrote:I'm assuming you are talking about Property Cafe? It doesn't look to me like Cafe can change file extension assignments at all.
Thats exactly what it does! It has a slick interface, and an easy assignment method including associating more than one app with an extension.

I suggest you do a bit more research before you knock someone elses app - I doubt you would like it!

Ban

User avatar
Local
Posts: 238
Joined: Fri Aug 03, 2007 3:48 am

#5 Post by Local »

Banshee was talking about C.A.F.E http://www.portablefreeware.com/?id=1317
I'm not sure what property cafe is

It does the job that you are trying to do and is very good at it.
I'm looking forward to seeing how you approach your results though.
Just not on my PC yet =)

User avatar
lococobra
Posts: 127
Joined: Fri Aug 03, 2007 10:42 am
Location: USA
Contact:

#6 Post by lococobra »

Aww man, I only made this app because I couldn't find one that did it for me!!! I did a google for "Cafe file extension" and found property cafe, which is completely different. Wasn't trying to knock C.A.F.E :P

C.A.F.E. is awesome... 100x better than mine :(

Guess there will be no V.0.3. But thanks for telling me about it. I was seriously worried I'd end up destroying someone's registry with my software and I'd get sued or something..

XPect
Posts: 36
Joined: Tue Feb 07, 2006 4:38 am
Location: France

#7 Post by XPect »

I'll keep cafe for managing associated programs, but I also keep your idea for Icons.

The problem is that when you put your pendrive on a computer where you have not a lot of program installed, all icons look the same and it's quite difficult to quickly identify the files.

Based on your idea, I'm actually trying a script to reassign icons on the fly when you start your pendrive and put back the registry in his previous state when you disconnect.

Will let you know the code if it work.

Banshee
Posts: 15
Joined: Thu Jan 25, 2007 2:20 am

#8 Post by Banshee »

lococobra wrote:Aww man, I only made this app because I couldn't find one that did it for me!!! I did a google for "Cafe file extension" and found property cafe, which is completely different. Wasn't trying to knock C.A.F.E :P

C.A.F.E. is awesome... 100x better than mine :(

Guess there will be no V.0.3. But thanks for telling me about it. I was seriously worried I'd end up destroying someone's registry with my software and I'd get sued or something..
My bad! I assumed that we were talking about the same CAFE application (and there's me lecturing about doing your research, ahem - sorry)

Still don't give up just like that! The icon idea is a good one, also CAFE is not without its problems, I have already posted to the author a couple of annoying quirks (main one being a double click on the top left of an explorer window executes the last application opened, at least for me...)

isn't it nice that despite the confusion no-one descended into unpleasantness/rudeness. That makes a really refreshing change for me in my experience of forums....

Ban

User avatar
lococobra
Posts: 127
Joined: Fri Aug 03, 2007 10:42 am
Location: USA
Contact:

#9 Post by lococobra »

The icon idea is very doable... other than one problem.

As I said before, the icon cache makes icon changes take forever. Sure I can assign a new icon to any file extension... but how long will it take to actually take effect? Probably around 5 minutes.

I've been looking into ways to force windows to refresh the icon cache, the most promising is by setting...

HKEY_CURRENT_USER\Control Panel\Desktop\WindowMetrics\Shell Icon Size

To a different value, then switching it back. Unfortuneately.. unless you perform some crazy windows magic... windows doesn't even realize you changed it.

If someone here can find me a program/script/method that refreshes the icon cache, I'll work on making a script that just changes icons.

User avatar
grannyGeek
Posts: 218
Joined: Mon Mar 26, 2007 10:54 pm

#10 Post by grannyGeek »

How about this:
refresh icon cache by deleting the IconCache.db file from your profile directory (usually /Documents and Settings/Username/Local Settings/Application Data). It will be automatically recreated.

Is this something that you can do from your script? It doesn't need admin rights to perform this action.

I do like the idea of assigning custom icons, please keep developing this tool.


EDIT ADDED -
I'm so sorry -- on second thought, I think this needs a re-boot to make it create the new db file. But maybe it will give you food for thought.

User avatar
lococobra
Posts: 127
Joined: Fri Aug 03, 2007 10:42 am
Location: USA
Contact:

#11 Post by lococobra »

Yeah, deleting shelliconcache.db/iconcache.db will not refresh the cache immediately.

Here's a similar idea to what I was talking about: http://www.swissdelphicenter.ch/torry/s ... hp?id=1054

The part I don't know how to replicate is:

SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, SPI_SETNONCLIENTMETRICS, 0, SMTO_ABORTIFHUNG, 10000, success);

User avatar
grannyGeek
Posts: 218
Joined: Mon Mar 26, 2007 10:54 pm

#12 Post by grannyGeek »

I saw something a long time ago that you can force a refresh by changing color depth in Desktop Properties, and changing it back again, but maybe that will end up behaving the same way as changing the icon setting in Desktop Properties.

Meanwhile, my Google mouse-finger got itchy, and someone made an AutoHotkey script to do custom icon assignments, but I know nothing about AHK or how to compile it, so I don't know if that script is "borrowable" <is that a real word?>

http://www.autohotkey.com/forum/topic94 ... ns+manager

XPect
Posts: 36
Joined: Tue Feb 07, 2006 4:38 am
Location: France

#13 Post by XPect »

I've done this (AutoIt script) to manage icon assignment (WARNING it's only the assignment of the Icon there is no restore for the moment)

The idea beyong this is to assign icons but in the less intrusive way possible and to restore the original settings after.

It work but I'm also stuck with the refresh of the icons.

I will see the differents solutions you mentioned.

Any comments are welcome

Code: Select all

;#NoTrayIcon
#include <File.au3>

;Association definition is set in an ini file (by default assoc.ini supposed to be in the script dir)

;Read command line to get ini file name - if no file specified, search for assoc.ini in the script directory
If $cmdline[0]>0 Then
	$iniFile=$cmdline[1]
Else
	$inifile="assoc.ini"
EndIf

;Test ini file existence and exit if file not found
If Not(FileExists($inifile)) Then
	MsgBox(16,"Warning","File " & $inifile & " not found, please check parameters")
	Exit
EndIf

;Delete Errors section in the ini file to track possible errors
IniDelete($iniFile, "Errors")


;Read icons path in ini file
$IconsPath=IniRead($inifile, "General", "IconsPath", ".\Icons\")
If StringRight($IconsPath, 1) <> "\" Then
	$IconsPath = $IconsPath & "\"
EndIf

;Test the path mentionned in the ini file to see if it's a relative path or not
If StringLeft($IconsPath,1) = "\" Then
	$IconsPath = StringLeft(@WorkingDir, 2) & $IconsPath
Else
	If StringLeft($IconsPath,1) = "." or StringMid($IconsPath, 2, 1) <> ":" Then 
		;Path start with . or .. or doesn't start with X: so it's also relative
		$IconsPath = _PathFull(@WorkingDir & "\" & $IconsPath)
	EndIf
EndIf

;Test if location exist
;todo évaluer les variables d'environnement en %
If Not(FileExists($IconsPath)) Then
	IniWrite($iniFile, "Errors", "Icons directory not found", $IconsPath)
	MsgBox(16,"Warning", "Icons directory " & $IconsPath & " not found, please check ini file and icons location")
	Exit
EndIf

;We have checked that ini file and Icons directory exist so job really start here

;Delete saved and errors section in ini file to store new settings
IniDelete($iniFile, "Saved")

;Read Icons section in inifile
$Icons = IniReadSection( $IniFile, "Icons" )
If @error Then
	MsgBox(16, "Warning", "Icons section not find in the file " & $IniFile )
	Exit
Else
	$nbIcons=$Icons[0][0]
	
	For $i=1 to $nbIcons step 1

		;Check the new Icon
		If FileExists($IconsPath & $Icons[$i][1]) Then
		
			;Check the registry
			$1stKeyValue=RegRead("HKEY_CLASSES_ROOT\." & $Icons[$i][0],"")
			If @error = 1 Then ;Primary key not found
				;Write information in the ini file
				IniWrite($iniFile, "Saved", $Icons[$i][0], "--No1stKey")
				;No 1st Key => Create 1st Key (.xxx) and associated 2nd Key (__xxx\DefaultIcon)
				RegWrite("HKEY_CLASSES_ROOT\." & $Icons[$i][0], "", "REG_SZ", "__" & $Icons[$i][0])
				RegWrite("HKEY_CLASSES_ROOT\__" & $Icons[$i][0] & "\DefaultIcon", "", "REG_SZ", $IconsPath & $Icons[$i][1])
			Else
				If $1stKeyValue="" Then ;Primary key found, but no associated value
					;Write information in the ini file
					IniWrite($iniFile, "Saved", $Icons[$i][0], "--No1stValue")
					;1st Key exist but no value => 1st Key value creation (.xxx default value) and creation of the associated 2nd Key (__xxx\DefaultIcon)
					RegWrite("HKEY_CLASSES_ROOT\." & $Icons[$i][0], "", "REG_SZ", "__" & $Icons[$i][0])
					RegWrite("HKEY_CLASSES_ROOT\__" & $Icons[$i][0] & "\DefaultIcon", "", "REG_SZ", $IconsPath & $Icons[$i][1])
				Else
					;Read second key linked to the 1st one
					$2ndKeyValue=RegRead("HKEY_CLASSES_ROOT\" & $1stKeyValue & "\DefaultIcon" ,"")
					If @error = 2 Then ;Second main key not found
						;Write information in the ini file
						IniWrite($iniFile, "Saved", $Icons[$i][0], "--No2ndMainKey")
						;We have found the 1st Key value, but there is no corresponding key in the registry (this is clearly a mess in the registry)
						;We don't care about the mess and create the value
						RegWrite("HKEY_CLASSES_ROOT\" & $1stKeyValue & "\DefaultIcon", "", "REG_SZ", $IconsPath & $Icons[$i][1])
					Else
						If @error = 1 Then ;Second key not found
							;Write information in the ini file
							IniWrite($iniFile, "Saved", $Icons[$i][0], "--No2ndKey")
							;We have found the 1st Key value and there is a corresponding key in the registry but no default Icon
							RegWrite("HKEY_CLASSES_ROOT\" & $1stKeyValue & "\DefaultIcon", "", "REG_SZ", $IconsPath & $Icons[$i][1])
						Else
							If $2ndKeyValue = "" Then ;Second key found but no associated value
								;Write information in the ini file
								IniWrite($iniFile, "Saved", $Icons[$i][0], "--No2ndValue")
								;We have found the 1st Key value and there is a corresponding key in the registry but no value in the default Icon
								RegWrite("HKEY_CLASSES_ROOT\" & $1stKeyValue & "\DefaultIcon", "", "REG_SZ", $IconsPath & $Icons[$i][1])
							Else
								;Everything ok, we can save the key
								;Write information in the ini file
								IniWrite($iniFile, "Saved", $Icons[$i][0], $2ndKeyValue)
								RegWrite("HKEY_CLASSES_ROOT\" & $1stKeyValue & "\DefaultIcon", "", "REG_SZ", $IconsPath & $Icons[$i][1])
							EndIf
						EndIf
					EndIf
				EndIf
			EndIf
		
			;IniWrite($iniFile, "Saved", $Icons[$i][0], $ActualIcon)
			;MsgBox(4096, "", "Key: " & $Icons[$i][0] & @CRLF & "Value: " & $Icons[$i][1] & @CRLF & "Reg: " & $1stKey & @CRLF & "Value: " & $ActualIcon)
			
		Else ;New Icon not found just write an error log in the ini file
			IniWrite($iniFile, "Errors", $Icons[$i][0], $Icons[$i][1] & " not found in " & $IconsPath)
		EndIf
	Next
	
EndIf
and the ini file structure as an example:

Code: Select all

[General]
;Path starting with . or .. or just a text is considered relative to working dir
;Path starting with X: is absolute
;Path starting with \ is considered absolute on the working drive
;The example below consider that icons are strored in the subdir Icons of the working dir
IconsPath=D:\_PSuite\Icons\Files

[Icons]
;CD images
b5i=cd-red.ico
b5t=cd-red.ico
bin=cd-blue.ico
bwi=cd-red.ico
ccd=cd-red.ico
cue=cd-blue.ico
iso=cd-green.ico
isz=cd-red.iso
mdf=cd-orange.ico
mds=cd-orange.ico
nrg=cd-orange.ico
pdi=cd-orange.ico
uif=cd-red.ico

;Documents
doc=doc-doc.ico
hlp=doc-hlp.ico
mdb=doc-mdb.ico
nfo=doc-nfo.ico
pdf=doc-pdf.ico
pps=doc-pps.ico
ppt=doc-ppt.ico
pub=doc-pub.ico
txt=doc-txt.ico
wri=doc-wri.ico
xls=doc-xls.ico

[Saved]
b5i=--No1stKey
b5t=--No1stKey
bin=C:\Program Files\DAEMON Tools\awxDTools.dll,0
bwi=--No1stKey
ccd=D:\_PSuite\Icons\Files\cd-blue.ico
cue=D:\_PSuite\Icons\Files\cd-red.ico
iso=C:\Program Files\7-Zip\7z.dll,8
mdf=D:\_PSuite\Icons\Files\cd-blue.ico
mds=D:\_PSuite\Icons\Files\cd-orange.ico
nrg=D:\_PSuite\Icons\Files\cd-orange.ico
pdi=D:\_PSuite\Icons\Files\cd-orange.ico
uif=--No1stKey
doc=C:\WINNT\Installer\{0002040C-78E1-11D2-B60F-006097C998E7}\wordicon.exe,1
hlp=%SystemRoot%\System32\shell32.dll,23
mdb=C:\WINNT\Installer\{0010040C-78E1-11D2-B60F-006097C998E7}\accicons.exe,1
nfo=C:\Program Files\Fichiers communs\Microsoft Shared\MSInfo\MSInfo32.exe,0
pdf=--No2ndKey
pps=C:\WINNT\Installer\{0002040C-78E1-11D2-B60F-006097C998E7}\pptico.exe,4
ppt=C:\WINNT\Installer\{0002040C-78E1-11D2-B60F-006097C998E7}\pptico.exe,1
pub=--No1stKey
txt=%SystemRoot%\system32\shell32.dll,-152
wri="%ProgramFiles%\Windows NT\Accessoires\WORDPAD.EXE",2
xls=C:\WINNT\Installer\{0002040C-78E1-11D2-B60F-006097C998E7}\xlicons.exe,1

[Errors]
isz=cd-red.iso not found in D:\_PSuite\Icons\Files\

User avatar
tproli
Posts: 1172
Joined: Sat Sep 09, 2006 10:14 am
Location: Hungary
Contact:

#14 Post by tproli »

Check out Assox, it's a very similar tool but has plenty of nice features. Still in beta.

Assox

Don't miss the video section: Demo videos

User avatar
joby_toss
Posts: 2971
Joined: Sat Feb 09, 2008 9:57 am
Location: Romania
Contact:

#15 Post by joby_toss »


Post Reply