Valhalla Legends Archive

Programming => General Programming => Visual Basic Programming => Topic started by: Kaiory on May 25, 2005, 05:32 PM

Title: Starting a visual basic program.
Post by: Kaiory on May 25, 2005, 05:32 PM
If done some light searching and am still trying to find it but, how can I make my visual basic program start when windows starts?
Title: Re: Starting a visual basic program.
Post by: MyndFyre on May 25, 2005, 05:37 PM
Quote from: Kaiory on May 25, 2005, 05:32 PM
If done some light searching and am still trying to find it but, how can I make my visual basic program start when windows starts?
Put it (or a shortcut to it) in the Startup folder in your Start menu.

Alternatively, add it to (HKCU or HKLM)\SOFTWARE\Microsoft\Windows\CurrentVersion\Run.  Create a new String value with a title and the fully-qualified path to the image.
Title: Re: Starting a visual basic program.
Post by: Kaiory on May 25, 2005, 05:41 PM
Thanks for the reply, but I mean through visual basic. Is there a command for it to start with windows?
Title: Re: Starting a visual basic program.
Post by: MyndFyre on May 25, 2005, 05:48 PM
Quote from: Kaiory on May 25, 2005, 05:41 PM
Thanks for the reply, but I mean through visual basic. Is there a command for it to start with windows?

That doesn't make sense.  Programs don't control Windows at start-up; Windows controls programs at start-up.  Which means, if you want to run a program at start-up, you need to do one of the things I listed above.

You can set a registry key through VB, although it should be done at an installation program that will automatically undo it at uninstallation.  Googling for "set registry value visual basic" should yield some great results.
Title: Re: Starting a visual basic program.
Post by: Kaiory on May 25, 2005, 05:49 PM
Yes, I relized that would be a very good alternative because I was still thinking there was a command.  But thanks a great deal, that helped a lot.
Title: Re: Starting a visual basic program.
Post by: R.a.B.B.i.T on May 25, 2005, 06:16 PM
1. Open DOS/Command Prompt
2. shortcut /f:"^%WINDIR^%\Startup\MyProgram.lnk" /a:c /t:"C:\Path\To\Program.exe"
3. Hit enter
4. Close
Title: Re: Starting a visual basic program.
Post by: Yegg on May 26, 2005, 02:21 PM
If you do what rabbit suggested, maybe you can use the Shell command in VisualBasic6 (I'm not sure if Shell has that capability, maybe you'll have to use something else) to do that task.
Title: Re: Starting a visual basic program.
Post by: Kaiory on May 26, 2005, 04:59 PM
I could have it open a bash file. Which would work fine.
Title: Re: Starting a visual basic program.
Post by: MyndFyre on May 26, 2005, 05:13 PM
Quote from: Yegg on May 26, 2005, 02:21 PM
If you do what rabbit suggested, maybe you can use the Shell command in VisualBasic6 (I'm not sure if Shell has that capability, maybe you'll have to use something else) to do that task.

You could, but you'd have to have Windows run the program that has the Shell command in it.
Title: Re: Starting a visual basic program.
Post by: R.a.B.B.i.T on May 26, 2005, 05:46 PM
cmd, or command, depending on the version of Windows.
Title: Re: Starting a visual basic program.
Post by: Warrior on May 26, 2005, 06:11 PM
Just write to the registry, it isn't hard.
Title: Re: Starting a visual basic program.
Post by: MyndFyre on May 26, 2005, 06:53 PM
Look guys, one way or the other, something has to go into Startup or into registry \Software\Microsoft\Windows\CurrentVersion\Run.  Those are the two easiest ways to make something start at startup for user mode.  Want it to run for everyone?  Put it in HKLM or in All Users\Start Menu\Programs\Startup.

Otherwise, you're going to have to put it into a service process that is configured to be able to interact with the usermode desktop, or into a kernel-mode driver that's going to need a user-mode component to start up like I suggested anyway.

No matter what you end up trying to do, this is how you have something start with Windows.  Making a bash file?  You'll have to put the batch command line into one of the startup paths.  Making a shortcut?  It has to go into the startup menu.