Launching my application using windows RunOnce method

1

I'm running my application installer on Windows 7 startup followed by a system restart requested by the installer. Now for the approach I'm writing to RunOnce registry key so that my installer run only once and the entry gets deleted automatically afterwards.

Now the above approach is working good except one thing: I'm not able to show the desktop by this method until the installation has finished and it is closed.

I think that this behaviour is default for RunOnce method. Wanted to confirm that and if required I can use the Run instead RunOnce key and delete the entry from there once my job is done. Is there any other way to do play around with RunOnce key?

hypheni

Posted 2015-05-15T08:42:35.493

Reputation: 121

Are you trying to run your installer silently, basically? Is the installer an MSI? – Kinnectus – 2015-05-15T08:45:29.227

@BigChris: It's NSIS installer. Actually its the .NET Framework 4.0 which is being silently installed from my installer and that requires a system reboot. And I cannot ignore this reboot as my installation is dependent on some of .NET components. – hypheni – 2015-05-15T08:47:40.933

But you haven't said what you exactly want... do you want there to be no display of your installer at all whilst it's running entirely? – Kinnectus – 2015-05-15T08:52:22.293

@BigChris: I want default behavior of Windows. i.e. My application installer should run just like when I double click on it. With explorer view. What I think is, RunOnce approach somehow blocking explorer. – hypheni – 2015-05-15T08:54:23.927

Possibly. What you may want to try is a Scheduled Task. Set the Trigger to be At log on and Any user. In the Settings tab set the task to Delete the task if it is not scheduled to run again and set the dropdown to Immediately. This will create a Scheduled Task to run when the next user logs in and because the task is not scheduled to run again it will be immediately deleted - effectively creating a one-time task that will run when you log in...? – Kinnectus – 2015-05-15T09:12:52.530

@BigChris: No that can't be a solution to add a scheduled task. It's better to handle it with regitry method. Please see my answer below. – hypheni – 2015-05-15T15:36:49.413

Answers

1

The answer is I need to use the RunOnce method of HKCU instead of HKLM. The order in which windows execute the startup entries is:

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunServicesOnce

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunServices

<Logon Prompt>

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnce

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run

StartUp Folder

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce

Ref: INFO: Run, RunOnce, RunServices, RunServicesOnce and Startup

hypheni

Posted 2015-05-15T08:42:35.493

Reputation: 121