PDA

View Full Version : File Associations


LoRd_MuldeR
14th October 2006, 18:13
That's my NSIS script to set File Asscociations:


Section
DeleteRegKey HKCR ".foo"
WriteRegStr HKCR ".foo" "" "FooFile"

WriteRegStr HKCR "FooFile" "" "Foo File Type"
WriteRegStr HKCR "FooFile\DefaultIcon" "" "foo.exe,0"
WriteRegStr HKCR "FooFile\shell" "" "open"
WriteRegStr HKCR "FooFile\shell\open\command" "" 'foo.exe "%1"'

System::Call 'Shell32::SHChangeNotify(i 0x8000000, i 0, i 0, i 0)'
SectionEnd


Seems to work so far.
BUT: Sometimes it's neccesarry to open Explorer, goto Extras > Options > File Types, seach the new file type in the list and click the "Restore" button. If you don't do that, it'll open the files with the old app. Why is that and is there a way to fix it in my NSIS script ???

LoRd_MuldeR
22nd October 2006, 13:59
Seems I found the answer ;)

File Asscociations are not only stored at
HKEY_CLASSES_ROOT\.foo
They are also stored here
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.foo

To set it up properly, it needs to clean up both locations!



Section
DeleteRegKey HKCR ".foo"
DeleteRegKey HKCU "Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.foo"
WriteRegStr HKCR ".foo" "" "FooFile"

DeleteRegKey HKCR "FooFile"
WriteRegStr HKCR "FooFile" "" "Foo File Type"
WriteRegStr HKCR "FooFile\DefaultIcon" "" "foo.exe,0"
WriteRegStr HKCR "FooFile\shell" "" "open"
WriteRegStr HKCR "FooFile\shell\open\command" "" 'foo.exe "%1"'

System::Call 'Shell32::SHChangeNotify(i 0x8000000, i 0, i 0, i 0)'
SectionEnd