VB School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Run on Startup Vb Rate Topic: -----

#1 netpumber  Icon User is offline

  • New D.I.C Head
  • Pip

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 27-October 06


Dream Kudos: 0

Share |

Run on Startup

Posted 23 February 2007 - 07:15 AM

Hallo! I have create a app in vb and i want to make it to run on startup of windows . does any1 know how to do that?
Thanxxxx.
Was This Post Helpful? 0
  • +
  • -


#2 the_hangman  Icon User is offline

  • D.I.C Addict
  • Icon

Reputation: 8
  • View blog
  • Posts: 602
  • Joined: 18-January 06


Dream Kudos: 200

Re: Run on Startup

Posted 23 February 2007 - 07:33 AM

What version of VB are you using?

For VB.NET I use the following...

		Dim xy As Microsoft.Win32.RegistryKey
		xy = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", True)
		xy.SetValue("ProgramNameHere", Application.StartupPath + "\ProgramNameHere.exe")
		xy.Close()


You may be able to adapt that to a different version if need be
Was This Post Helpful? 0
  • +
  • -

#3 netpumber  Icon User is offline

  • New D.I.C Head
  • Pip

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 27-October 06


Dream Kudos: 0

Re: Run on Startup

Posted 23 February 2007 - 09:42 AM

Visual Basic 6
Was This Post Helpful? 0
  • +
  • -

#4 huzi8t9  Icon User is offline

  • D.I.C Head
  • Icon

Reputation: 8
  • View blog
  • Posts: 113
  • Joined: 11-July 07


Dream Kudos: 100

Re: Run on Startup

Posted 11 February 2008 - 11:08 PM

View Postnetpumber, on 23 Feb, 2007 - 10:42 AM, said:

Visual Basic 6


Well, registry doesnt always work for me so I use the WIN.INI like so

Public Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long

Public Function AddAtStart()
windir = Environ("windir")
WritePrivateProfileString "Files", _
							"load", _
							App.Path & "\" & App.EXEName & ".exe", _
							windir & "\WIN.INI"

End Function


Any problems. Let me know B)
Was This Post Helpful? 0
  • +
  • -

#5 born2c0de  Icon User is offline

  • printf("I'm a %XR",195936478);
  • Icon

Reputation: 137
  • View blog
  • Posts: 4,622
  • Joined: 26-November 04


Dream Kudos: 2825

Expert In: J2ME, 80x86 Assembly, C/C++, VB6, VB.NET, C#, J2SE, Win32 API, Reversing

Re: Run on Startup

Posted 12 February 2008 - 05:28 AM

The registry is to be used to store Startup Information. Although win.ini can start files, its use as an autostart launcher is likely to be deprecated.

Use this instead. It's a lot easier to use than the Win32 API Alternative.
	Dim Startup_key As String
	Startup_key = "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run\"
	Dim Reg As Object
	Set Reg = CreateObject("wscript.shell")
	Reg.RegWrite Startup_key & App.EXEName, App.Path & "\" & App.EXEName & ".exe"

Was This Post Helpful? 1



Fast Reply

  

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users