Jump to content

File Type Association


Recommended Posts

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

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

Not 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 by FlyinRiz
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...