how to automaticlly run the software when the system is boot up
hi to all. i want to run the aoftware automatically, when the system is boot up?. when i run the first time, i will give the input. after that, it will run and given the output(the window may be hidden) and also , given if any error occurs, otherwise, we can't see the window. and also it will continue the process, when the system is boot up?. how can i achieve that.Plz help me to do that. plz anybody know help me.
Thanks
MMary
Re: how to automaticlly run the software when the system is boot up
You need to add a key-value pair to the following registry key:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
You can do this as follows.
Paste this into a module:
Code:
'for accessing windows registry
Imports Microsoft.Win32
Module modRegistry
Public Sub UpdateRegistryLocalMachine(ByRef sRegPath As String, _
ByRef sKeyName As String, ByRef sValue As String, _
ByRef bWritable As Boolean)
Dim regKey As RegistryKey
regKey = Registry.LocalMachine.CreateSubKey(sRegPath, RegistryKeyPermissionCheck.Default)
regKey = Registry.LocalMachine.OpenSubKey(sRegPath, bWritable)
With regKey
.SetValue(sKeyName, sValue)
.Close()
End With
End Sub
End Module
Implement as follows:
Code:
Dim sRegPath As String = "SOFTWARE\Microsoft\Windows\CurrentVersion\Run"
Dim sKeyName As String
Dim sValue As String
sKeyName = 'assign the name of your application. This will appear in the 'Startup Item' column of the Startup tab of the System Configuration Utility
sValue = 'assign the FULL path to your application's executable
UpdateRegistryLocalMachine(sRegPath, sKeyName, sValue, True)
Re: how to automaticlly run the software when the system is boot up
will u please send the details of how to create the registry service (in the same application i have developed or new application)?. plz send the details.
with thanks and regards
MMAry
Re: how to automaticlly run the software when the system is boot up
I have given quite a detailed explanation of what to do. What don't you understand?
Re: how to automaticlly run the software when the system is boot up
hi thanks for ur reply. i have to create one more class to add that module or i have to add that module with in the same application. and another doubt is
in the sKeyName i have to specify the name of the software only or full path.and also what is SValue. and one more doubt is i have to set the details in my software one time is possible or everytime i have to get the information from the user.
with thanks and regards
MMary
Re: how to automaticlly run the software when the system is boot up
sKeyName
This is the name of your application. This is not so important to get this to work. It is just so that you can identify the setting in the Registry Editor or the System Configuration Utility.
If you go to the Run menu and type in "msconfig", this will launch the System Configuration Utility. If you click on the "Startup" tab this will display all of the programs that will start when you boot your computer. Only the checked items will start. Notice that each application is named in the "Startup Item" column. What you pass to UpdateRegistryLocalMachine as sKeyName will appear in this column.
sValue
This is very important. Assign the full path of the executable file for the program that you want to start when your computer starts.
Example
Let me give you an example. If you want Notepad to start when you start your computer, pass the following:
sKeyName = "Notepad"
sValue = "C:\WINDOWS\NOTEPAD.EXE"
If you run this procedure, next time you start your computer, an empty notepad window will appear:
Code:
UpdateRegistryLocalMachine("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "Notepad", "C:\WINDOWS\NOTEPAD.EXE", True)
You only need to run this once and notepad will start every time you restart your computer until this key is either deleted from the Registry Editor or is unchecked from the Startup tab in the System Configuration Utility.
I hope this helps.
Re: how to automaticlly run the software when the system is boot up
Thank u sir, thank u for ur kind reply. and i am haveing one more doubt. plz clear that.wher to call that function "UpdateRegistryLocalMachine("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "Notepad", "C:\WINDOWS\NOTEPAD.EXE", True)". In that Main() function or some where else. and how can i execute this?. plz help me sir.
with thanks and Regards
MMary
Re: how to automaticlly run the software when the system is boot up
If you want to do it in code then just do this:
vb Code:
My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", _
Application.ProductName, _
Application.ExecutablePath)
and you only need to do it once.
Note that that will run that app at startup for all users. If you just want it for the current user then specify HKEY_CURRENT_USER instead of HKEY_LOCAL_MACHINE.
Note also that if you're not using VB 2005 (please specify in future) then you should use Microsoft.Win32 instead of My.Computer.
Re: how to automaticlly run the software when the system is boot up
thank u for ur kind reply. i am honestly telling i don't know about the windows service. please tell where to put that code in the static main method or somewhere else.
With thanks and regards
MMary
Re: how to automaticlly run the software when the system is boot up
thank u for ur kind reply. plz tell me, where to put the code in my application ?
plz help me
plz help me
Thanks and Regards
MMary
Re: how to automaticlly run the software when the system is boot up
You put it wherever you want it executed. Like I said, you only need to execute it once. Once the registry value is set it doesn't need to be set again. It's up to you to decide where is appropriate to execute it and put it there.
Also, if you really are going to create a Windows Service then you won't be starting it like that anyway.