Change exe file association for single user

2

it is relatively easy to set the file association for exe files in windows (a nice way to lock yourself out, btw). This is typically done in the HKEY_CLASSES_ROOT, which is valid for all users. But is there a way to change this association only for a single user?

I want to perform some action every time before some program is started by this user. The launcher should then call the program. However, CreateProcess does not work if elevation is required, while ShellExecute will run the launcher recursively... - so the idea was to execute the program from a different user which has not set the file association for the exe file.

Is there a way to achieve this?

LionAM

Posted 2015-01-24T01:33:54.337

Reputation: 121

This is an interesting question. I don't know that there is a solution for what you're looking for, but it is a pretty spiffy "would be nice" feature. +1 for that. (and I don't even like windows) – killermist – 2015-01-24T01:58:12.497

@killermist: Yes, you can; just use HKCU\Software\Classes – SLaks – 2015-10-11T19:40:34.590

@SLaks is correct about setting a file association for a single user, but it doesn't sound like this solves your problem. As you say, ShellExecute will just recursively call itself (unless you set the association to an executable file type that is not .exe). If you want a specific program to run through some launcher, you probably want Image File Execution Options.

– CBHacking – 2015-10-11T19:51:55.620

@CBHacking: I'm pretty sure ShellExecute will not recurse. I've seen messed-up systems where exefile was changed, and it properly launched the wrong program (and was useless); it did not give any kind of stack overflow. – SLaks – 2015-10-11T19:59:52.763

Answers

0

Yes.

HKCR is an amalgamation of HKLM\Software\Classes and HKCU\Software\Classes.

You can simply create HKCU\Software\Classes\.exe and change the file association for the current user only.

SLaks

Posted 2015-01-24T01:33:54.337

Reputation: 7 596