Program Start Up

Please support our VB.NET advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
Reply

Join Date: Sep 2008
Posts: 130
Reputation: rajeesh_rsn is an unknown quantity at this point 
Solved Threads: 0
rajeesh_rsn rajeesh_rsn is offline Offline
Junior Poster

Program Start Up

 
0
  #1
Nov 30th, 2008
Hai I am Rajeesh.
New to Vb.net. I am developing a simple program. I want to run my application automatically when windows start. Please tell me how can I do this adding Windows Registry key.....

Thanks
Rajeesh
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 2,640
Reputation: Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light 
Solved Threads: 245
Jx_Man's Avatar
Jx_Man Jx_Man is offline Offline
Posting Maven

Re: Program Start Up

 
0
  #2
Nov 30th, 2008
just copying your .exe file into startup folder.
you can use special folder to do this.
Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 130
Reputation: rajeesh_rsn is an unknown quantity at this point 
Solved Threads: 0
rajeesh_rsn rajeesh_rsn is offline Offline
Junior Poster

Re: Program Start Up

 
0
  #3
Dec 1st, 2008
How can I do it in registry editor ...
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 710
Reputation: Teme64 will become famous soon enough Teme64 will become famous soon enough 
Solved Threads: 114
Teme64's Avatar
Teme64 Teme64 is offline Offline
Master Poster

Re: Program Start Up

 
0
  #4
Dec 1st, 2008
You mean that you want to start up your application from the registry?

Install application to run from the registry:
  1. ''' <summary>
  2. ''' Installs an application to start from the registry when Windows starts
  3. ''' </summary>
  4. ''' <param name="AppName">Application's name</param>
  5. ''' <param name="AppPath">Full path to the application</param>
  6. ''' <param name="InstallToLocalMachine">Install to LM, otherwise install to current user</param>
  7. ''' <returns>True if successfully installed</returns>
  8. ''' <remarks>Compatible with Windows XP and Vista</remarks>
  9. Public Function StartUpInstall(ByVal AppName As String, ByVal AppPath As String, _
  10. ByVal InstallToLocalMachine As Boolean) As Boolean
  11. '
  12. ' Install to registry
  13. ' If LM then uses HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
  14. ' Otherwise uses HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
  15. '
  16. Dim RegRoot As RegistryKey
  17. Dim RegKey As RegistryKey
  18.  
  19. Try
  20. If InstallToLocalMachine Then
  21. RegRoot = Microsoft.Win32.Registry.LocalMachine
  22. RegKey = RegRoot.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", _
  23. RegistryKeyPermissionCheck.ReadWriteSubTree, _
  24. Security.AccessControl.RegistryRights.SetValue)
  25. RegKey.SetValue(AppName, AppPath, RegistryValueKind.String)
  26. Return True
  27. Else
  28. RegRoot = Microsoft.Win32.Registry.CurrentUser
  29. RegKey = RegRoot.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", _
  30. RegistryKeyPermissionCheck.ReadWriteSubTree, _
  31. Security.AccessControl.RegistryRights.SetValue)
  32. RegKey.SetValue(AppName, AppPath, RegistryValueKind.String)
  33. Return True
  34. End If
  35. Catch ex As Exception
  36. Return False
  37. End Try
  38.  
  39. End Function
Remove application from the registry:
  1. ''' <summary>
  2. ''' Uninstalls an application not to start from the registry when Windows starts
  3. ''' </summary>
  4. ''' <param name="AppName">Application's name</param>
  5. ''' <param name="InstallToLocalMachine">Uninstall from LM, otherwise uninstall from current user</param>
  6. ''' <returns>True if successfully uninstalled</returns>
  7. ''' <remarks>Compatible with Windows XP and Vista</remarks>
  8. Public Function StartUpUnInstall(ByVal AppName As String, _
  9. ByVal InstallToLocalMachine As Boolean) As Boolean
  10. '
  11. ' UnInstall from registry
  12. ' If LM then uses HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
  13. ' Otherwise uses HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
  14. '
  15. Dim RegRoot As RegistryKey
  16. Dim RegKey As RegistryKey
  17.  
  18. Try
  19. If InstallToLocalMachine Then
  20. RegRoot = Microsoft.Win32.Registry.LocalMachine
  21. RegKey = RegRoot.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", _
  22. RegistryKeyPermissionCheck.ReadWriteSubTree, _
  23. Security.AccessControl.RegistryRights.SetValue)
  24. RegKey.DeleteValue(AppName, False)
  25. Return True
  26. Else
  27. RegRoot = Microsoft.Win32.Registry.CurrentUser
  28. RegKey = RegRoot.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", _
  29. RegistryKeyPermissionCheck.ReadWriteSubTree, _
  30. Security.AccessControl.RegistryRights.SetValue)
  31. RegKey.DeleteValue(AppName, False)
  32. Return True
  33. End If
  34. Catch ex As Exception
  35. Return False
  36. End Try
  37.  
  38. End Function
I think I've originally grabbed these snippets from somewhere. So the credits go to someone who's name I don't remember anymore
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC