4
votes

I have a 32-bit application that writes to:

HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run

my application path so that it will be started when the current user logs on. This works fine on 32-bit systems (i.e. the application auto-starts).

I understand that on 64-bit systems, registry redirection comes into play. So, I searched for:

HKEY_CURRENT_USER\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Run

but the CurrentVersion sub-key does not exist (the Wow6432Node key exists though)! So, I manually created it and my application wrote correctly to the registry (I went into the registry and checked. The entry was there). BUT, the application did not auto-start when the current user logged in. Can someone tell me why?

Btw, all this is fine if I use the HKEY_LOCAL_MACHINE branch. But, I want this to be user-specific.

Why am I not just using the Startup folder?

When UAC is enabled and set to always notify, this simply does not work (i.e. my application does not auto-start). And no, I cannot disable UAC. I require that my application play nice with UAC enabled and set to always notify.

If someone can tell me why, I will gladly forget my need to use the registry (I hate the registry).

Fallback option (last resort):

I will use the Task Scheduler APIs to do this. But, I will do this only when there is absolutely no other way.

Thanks!

2
If you're running anti-virus software it may be preventing your application from modifying \CurrentVersion\Run in the registry. - Captain Obvlious
@CaptainObvlious, I checked the registry after closing the application. The expected entry was at the expected place. - Anish Ramaswamy
Might want to open up the Event Viewer (in Admin tools) and see if Windows reports an error during startup. If there's something wrong with your registry entry or launching the app in general there's a good change you will see an entry in the event viewer - Captain Obvlious
@CaptainObvlious, I checked the System and Application logs just now. No errors/information about the application in question. - Anish Ramaswamy
What happens when you write to HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run in a 64-bit OS? Does the registry key exist and it is not being launched or is the registry key not written? - Steve

2 Answers

0
votes

It is not possible to launch an executable requiring elevation from the user's Run key or from the Startup folder. See Elevations Are Now Blocked in the User's Logon Path from the UAC team's blog.

The best solution is probably to configure the executable to not require elevation. It can then launch an elevated copy of itself only if and when actually needed. Or you could use a service for the tasks that require elevation, this is the only good approach if you need to be able to perform elevated tasks on behalf of users who do not have administrator privilege.

Another option, since you can successfully launch the process using HKLM, would be to have it launch for all users but exit immediately if it isn't the user(s) you want.

1
votes

HKEY_CURRENT_USER is shared between 32-bit and 64-bit applications (there is no redirection and Wow6432Node key). Here is the list with Registry Keys Affected by WOW64.