erebus Posted December 17, 2007 Share Posted December 17, 2007 (edited) Hello all,I am using some piece of code by MHz found on this forum, using ftype and assoc to change file type associations on my system. Although the code works well (thanks for the trick!), it doesn't work always as expected. Here is the code:RunWait(@ComSpec & ' /c ftype Sample.Assoc.Doc=c:\windows\notepad.exe ' & '"%1"' & " && assoc .sample=Sample.Assoc.Doc", "", @SW_HIDE)This always work well for new filetypes (or for new filetypes I create using the above method), never existed on the system (i.e. ".sample" as in the above example). However, when trying to modify an existing old filetype like .torrent, sometimes the file association doesn't work, despite the fact that the above command is executed successfully. I can verify the successful execution using:C:\Documents and Settings\erebus>ftype Torrent.Doc && assoc .torrent Torrent.Doc=c:\progs\utorrent.exe "%1" .torrent=Torrent.DocEverything seems to be correct and both the .torrent and Torrent.Doc keys exist under HKCR in registry. However, when double clicking the specific filetype in Windows Explorer, it tries to open another program which is not found on the system (let's say the deleted bitlord.exe), which makes me believe that something was left behind from a previous installation (or an unsuccessful uninstallation). Also, if I open the File Types tab under Tools in Windows Explorer and choose the 'torrent' file type, Windows display the message (trying to translate it from Greek as I don't have English Windows): "You have set files with extension 'TORRENT'. To restore these files to default type 'BitLord' click on the Restore button.". However assoc and ftype continues to display correct values, while the association still doesn't work until I press the Restore button.My question is how can I check that no other settings for a specific file association have remained on the system and how can I clean them. I have already tried using 'ftype Torrent.Doc=' and 'assoc .torrent=' (which run successfully), however this didn't help.Thank you,P.S. Wasn't sure if this was the proper subforum for this discussion but posted here anyway... Edited December 17, 2007 by erebus Link to comment Share on other sites More sharing options...
erebus Posted December 17, 2007 Author Share Posted December 17, 2007 I have found something related stored in registry: Windows Registry Editor Version 5.00 [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.torrent] "Application"="iexplore.exe" [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.torrent\OpenWithList] "a"="utorrent.exe" "MRUList"="ebadc" "b"="firefox.exe" "c"="BitLord.exe" "d"="Azureus.exe" "e"="iexplore.exe" [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.torrent\OpenWithProgids] "torrentfile"=hex(0): "bittorrent"=hex(0): "uTorrent"=hex(0): "Azureus"=hex(0): "μTorrent"=hex(0): Assoc seems not to change these keys when setting a new file type association (or this happens when some unknown conditions occur?). If I delete this .torrent key before setting Assoc, the trick works (so far). Can anybody confirm if it is safe to delete these keys before setting filetype assocs? Thank you. Link to comment Share on other sites More sharing options...
ptrex Posted December 18, 2007 Share Posted December 18, 2007 (edited) @all Maybe this can help ;Sample Usage _Associate (".jpg", "JPGFile", "C:\Program Files\Accessories\MSPAINT.EXE") Func _Associate($EXT , $FileType, $FileName) Dim $oShell $oShell = ObjCreate("wscript.shell") $oShell.regwrite "HKCR\" & $EXT & "\", $FileType $oShell.regwrite "HKCR\" & $FileType & "\", "MY file" $oShell.regwrite "HKCR\" & $FileType & "\DefaultIcon\", $FileName $oShell.regwrite "HKCR\" & $FileType & "\shell\open\command\", $FileName & " %L" $oShell.regdelete "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\" & $EXT & "\Application" $oShell.regwrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\" & $EXT & "\Application", $FileName $oShell.regdelete "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\" & $EXT & "\OpenWithList\" $oShell.regwrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\" & $EXT & "\OpenWithList\a", $FileName Endfunc Regards, ptrex Edited December 18, 2007 by ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
SmLex 2006 Posted December 18, 2007 Share Posted December 18, 2007 (edited) If StringLower(StringRight(@ScriptFullPath, 3)) = "exe" Then #region; Creare date Registrii RegWrite("HKEY_CLASSES_ROOT\.devsl", "", "REG_SZ", "devsl_auto_file") RegWrite("HKEY_CLASSES_ROOT\devsl_auto_file\DefaultIcon", "", "REG_SZ", "c:\icon.ico ,1") RegWrite("HKEY_CLASSES_ROOT\devsl_auto_file\shell\open", "", "REG_SZ", "Open") RegWrite("HKEY_CLASSES_ROOT\devsl_auto_file\shell\open\command", "", "REG_SZ", @ScriptFullPath & ' "%1"') #endregion EndIf Edited December 18, 2007 by SmLex 2006 Link to comment Share on other sites More sharing options...
erebus Posted December 18, 2007 Author Share Posted December 18, 2007 @allMaybe this can helpHello,Is there any specific reason that you use object and not registry commands directly? Link to comment Share on other sites More sharing options...
ptrex Posted December 18, 2007 Share Posted December 18, 2007 @erebus Not realy I just grabed something from the net to give a direction on how to. I update the example to the correct AU3 syntax. But you can translate it to use the native AU3 functions as well. Good luck. regards ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
erebus Posted December 18, 2007 Author Share Posted December 18, 2007 Oh, I just was curious. It seems from your example and my research on this that the key Explorer\FileExts is really critical and that assoc and ftype doesn't handle this properly. I will try an approach which will hit the registry directly to see what will happen. Thank you all! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now