ogonzales Posted August 9, 2010 Share Posted August 9, 2010 Ok so here is what I am trying to accomplish but have been unsuccesful in doing this. I have two path but one function. Can anyone help please. If FileExists("C:\Progrm Files\Microsoft Office\Office11\Excel.exe") Then _FiletypeAssociation('.tsv', 'tsv', 'C:\Progrm Files\Microsoft Office\Office11\Excel.exe "%1"', 'TSV') ElseIF FileExists("C:\Progrm Files\Microsoft Office\Office12\Excel.exe") Then _FiletypeAssociation('.tsv', 'tsv', 'C:\Progrm Files\Microsoft Office\Office12\Excel.exe "%1"', 'TSV') EndIf Func _FiletypeAssociation($extension, $type, $program, $description = '') $exitcode = RunWait(@ComSpec & ' /c ftype ' & $type & '=' & $program & _ ' && assoc ' & $extension & '=' & $type, '', @SW_HIDE) If $description And Not $exitcode Then Return RegWrite('HKCR\' & $type, '', 'Reg_sz', $description) EndIf Return Not $exitcode EndFunc Exit Link to comment Share on other sites More sharing options...
FlyinRiz Posted August 9, 2010 Share Posted August 9, 2010 (edited) Ok so here is what I am trying to accomplish but have been unsuccesful in doing this. I have two path but one function. Can anyone help please.If FileExists("C:\Progrm Files\Microsoft Office\Office11\Excel.exe") Then _FiletypeAssociation('.tsv', 'tsv', 'C:\Progrm Files\Microsoft Office\Office11\Excel.exe "%1"', 'TSV')ElseIF FileExists("C:\Progrm Files\Microsoft Office\Office12\Excel.exe") Then _FiletypeAssociation('.tsv', 'tsv', 'C:\Progrm Files\Microsoft Office\Office12\Excel.exe "%1"', 'TSV')EndIf Func _FiletypeAssociation($extension, $type, $program, $description = '') $exitcode = RunWait(@ComSpec & ' /c ftype ' & $type & '=' & $program & _ ' && assoc ' & $extension & '=' & $type, '', @SW_HIDE) If $description And Not $exitcode Then Return RegWrite('HKCR\' & $type, '', 'Reg_sz', $description) EndIf Return Not $exitcode EndFunc ExitNot sure if you had copy/paste'd your script but there are a few typos like "progrm" instead of "program" and also if the path has spaces (i.e. C:\Progrm Files\Microsoft Office\Office12\Excel.exe) you need to surround it in double-quotes as well...hope that helps a little.-Aaron Edited August 9, 2010 by FlyinRiz 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