Jump to content
Sign in to follow this  
ogonzales

File Type Association

Recommended Posts

ogonzales

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

Share this post


Link to post
Share on other sites
FlyinRiz

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

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.