I have problem with making my program works on windows startup. Here's the code:

    Sub RunAtStartup(ByVal PutAtStartup As Boolean, ByVal Name As String, ByVal Path As String)
        Dim StartupPath As String = "Software\Microsoft\Windows\CurrentVersion\Run"
        Dim myKey As Microsoft.Win32.RegistryKey
        myKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(StartupPath, True)
        If PutAtStartup = True Then
            Try
                myKey.SetValue(Name, Path)
            Catch ex As Exception
                ErrLog &= ex.ToString & vbNewLine
            End Try
        Else
            Try
                myKey.DeleteValue(Name, False)
            Catch ex As Exception
                ErrLog &= ex.ToString & vbNewLine
            End Try
        End If
    End Sub

As you see above my program edit the registry on path "Software\Microsoft\Windows\CurrentVersion\Run" and the value it succefully inserted in the path. But the problem is my program dosen't works on windows startup what's the wrong?????

Note: my OS is windows 7 32bit.

Recommended Answers

All 7 Replies

well if you want to run you application at the startup of windows then you can simply do this ,
when you make setup of your application in vs , you have 3 items on your left ,
1-application folder
2-user desktop
3-i dont remember right now:P

on this list right click-->a pop up window will appear --> select User start up folder form the list . and press ok
now a new item is added in your list , then select it , and press right click on the right panel and add shortcut same as we add shortcut in user desktop folder.

Done :P

when ever you will start your computer your application will executed.

Regards

Mr. M.Waqas Aslam. your solution is not required for my application. I want to start my program in windows startup programmically not setup file or whatever you say.....
Do you have another solution?
I told you my program works at windows startup on windows xp only. But not on windows seven....?????!!!!!!

I don't know exactly how to do that in VB.net, but i think it can help you...
If you add a shortcut to your program in "C:\Users\ yourusername\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup" it starts with windows.
I think it doesn't work because the code you're wrinting is in your application, and don't run until your app is launched, so it needs to be running to start with windows <=PARADOX
Hope it helps :)

Well, this solution is not required for my program. Is there another solution to make my proogram works on windows startup using system registry.

My program set the value in registry successfully but it dosen't works on windows startup.

It helps to know WHAT OS you are running. XP handles start ups different then Vista/7/8. Also x86 handles different than x64 if there are lowlevel hooks.

There are 2 keys in Windows that deals with startup items

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run]

IF you place the link to your EXE in either one of them you should get it to start with windows.

With later versions [vista/7/8] you might look at setting up a schedule to load the software if it requires elevations.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.