Set Windows File Association

What other productivity software are you working with...
Post Reply
binocular222
Posts: 1410
Joined: 04 Nov 2008 05:35
Location: Hanoi, Vietnam

Set Windows File Association

Post by binocular222 » 17 May 2014 18:50

Example: Assign ext=.jpg to FileType=Image, then assign FileType=Image to ImageEye.exe seems to be an easy task, either via Registry:

Code: Select all

HKEY_CURRENT_USER\SOFTWARE\Classes\.jpg
default=Image

HKEY_CURRENT_USER\SOFTWARE\Classes\Image\Shell\Open\Command
Default="E:\4Media\Image Eye\x32\Image Eye.exe" "%1"
Or via Command promt

Code: Select all

assoc .jpg=Image
ftype Image="E:\4Media\Image Eye\x32\Image Eye.exe" "%1"
However, I got this problem: http://stackoverflow.com/questions/3620 ... ssociation
I have no permission to edit HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.jpg\UserChoice => Everything fail.

Now, anyone has any idea to change file association programmtically?
I'm a casual coder using AHK language. All of my xys scripts:
http://www.xyplorer.com/xyfc/viewtopic. ... 243#p82488

highend
Posts: 8147
Joined: 06 Feb 2011 00:33

Re: Set Windows File Association

Post by highend » 17 May 2014 20:09

These registry entries are protected (via ACL = access control list).

You have to modify those rights before...

Get SetACL from http://helgeklein.com/setacl/

and use it like this:

Code: Select all

SetACL.exe -on "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.jpg\UserChoice" -ot reg -actn clear -clr dacl -silent
One of my scripts helped you out? Please donate via Paypal or highend (at) web (dot) de

binocular222
Posts: 1410
Joined: 04 Nov 2008 05:35
Location: Hanoi, Vietnam

Re: Set Windows File Association

Post by binocular222 » 18 May 2014 08:09

Thanks, I used recursive (-rec yes) to evelate permission for the whole FileExts key :twisted:
run """E:\2System\SetACL\x32\SetACL.exe"" -on ""HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts"" -ot reg -actn clear -clr dacl,sacl -rec yes -log ""E:\2System\SetACL\SetACLreport.txt"" "
I'm a casual coder using AHK language. All of my xys scripts:
http://www.xyplorer.com/xyfc/viewtopic. ... 243#p82488

Post Reply