1

I am working on a vb.net windows 32 bit application. The application needs to startup. So I add the registry entry to rut it on windows startup. Also it is set to run as administrator.

The application starts fine on all OS except Win7 32 bit. It works fine for win 7- 64 bit.

On Win 7 32 bit: If i execute the application directly, it runs fine. But it does not starts at the time of windows startup.

How can the application be programmed to run at win 7 32 bit startup?

Raymond Chen
  • 44,448
  • 11
  • 96
  • 135
Harsh
  • 3,683
  • 2
  • 25
  • 41
  • possible duplicate of [Program needing elevation in Startup registry key (windows 7)](http://stackoverflow.com/questions/2293609/program-needing-elevation-in-startup-registry-key-windows-7) – Raymond Chen Jan 19 '12 at 14:37

4 Answers4

1

Try doing this

string regPath = @"Software\Microsoft\Windows\CurrentVersion\Run";
RegistryKey key = Registry.CurrentUser.CreateSubKey(regPath);
key.SetValue("YOUR KEY", Assembly.GetExecutingAssembly().Location); //Or your exe path

Hope this works for you.

Amar Palsapure
  • 9,590
  • 1
  • 27
  • 46
  • 1
    The logic or solution matters, Dexter ;) can easily convert these C# lines to VB.Net – Amar Palsapure Jan 20 '12 at 03:57
  • Thanks for the answer but the registry entry is fine on my end also. The issue was due to Win 7 & win vista OS. I am placing the ling in answer. – Harsh Jan 20 '12 at 05:37
1

The issue here is with Win Vista and win 7 32 bit. What happens in these versions is that the OS does not allows any application with admin privilege to run at startup.

Here is a blog entry of program manager of UAC http://blogs.msdn.com/b/uac/archive/2006/08/23/715265.aspx.

The good thing is this issue does not exists in win 7 64 bit and other OS. This is a vista issue due to which we developers face problems.

Hope this helps you.

Harsh
  • 3,683
  • 2
  • 25
  • 41
0

The is not the problem with the OS either your registry key is not read properly or it has not been set.

Might be your user don't have right in Win 7 32 User

Kishore Kumar
  • 12,675
  • 27
  • 97
  • 154
  • Even i thought so. but then i tried on two different win7 32bit box n the result was same. App not running. – Harsh Jan 19 '12 at 14:20
  • This may have a solution for your problem. Vote Up or Accept if it Works http://social.msdn.microsoft.com/Forums/en-US/windowscompatibility/thread/073349b1-0f29-41ef-aaab-dbb262d52457/ – Kishore Kumar Jan 19 '12 at 14:24
0

This is tested to work:

If True Then
    My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run", "YOUR_APP_NAME", Environment.GetCommandLineArgs(0))
Else
    My.Computer.Registry.LocalMachine.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Run", True).DeleteValue("YOUR_APP_NAME")
End If
Elmo
  • 6,409
  • 16
  • 72
  • 140
  • Thanks for help, but the issue is not registry entry here. I got this fixed. I am posting an answer for that. – Harsh Jan 20 '12 at 05:39