Solved

How to start application when windows start

Posted on 2002-04-29
6
167 Views
Last Modified: 2010-05-02
hi!

I want to start my application when windows start... i guess it must be possbile by manipulation registry


thanks in advance


nachiket
0
Comment
Question by:nachiket
  • 3
  • 2
6 Comments
 
LVL 3

Expert Comment

by:n_narayanan
ID: 6979722
You are right,

Here is the code for you,

 Needs a reference to the project "Windows Script Host Object Model" WSHOM.OCX
Public Sub EnableStartup()
    Dim cPGM As String
    Dim oShell As IWshRuntimeLibrary.IWshShell, frmMsgBox As frmMessageBox
    On Error GoTo ErrEnablestartup
    Set oShell = New IWshRuntimeLibrary.IWshShell_Class
   
   
    cPGM$ = App.Path & "\pmsg.exe"
    oShell.RegWrite "HKLM\Software\Microsoft\Windows\CurrentVersion\Run\PMSG", cPGM, "REG_SZ"
    Set oShell = Nothing
    Exit Sub
ErrEnablestartup:
    Dim strErr As String
    strErr = "Err no:" & Err.Number & " Err Desc:" & Err.Description & " Module:Global Proc:EnableStartup " & " Sts:Continue Process " & Date & " " & Time
    Call ErrorLog(strErr)
End Sub

'Where PMSG.EXE is your application name
0
 
LVL 4

Author Comment

by:nachiket
ID: 6979726
thanks for the help i will try this and come back in 2 hours
0
 
LVL 4

Author Comment

by:nachiket
ID: 6979951
hi

thanks for the help and it worked... can i ask for one more favor?? please!!!

after runnig this code one key is added in HKLM\Software\Microsoft\Windows\CurrentVersion\Run\PMSG which start the application successfully on windows startup... but the problem is suppose now i have added the program to startup and i want to disble this feature after words than??? i mean after i have once added the program to windows startup and i want to remove it afterwords than how to do that?

thank u very much for the help..  waiting.....

nachiket
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 3

Expert Comment

by:n_narayanan
ID: 6979991
I will put the code in few Mins.

Your points for this is very less!!!

Just joking...

Narayanan
0
 
LVL 3

Accepted Solution

by:
n_narayanan earned 100 total points
ID: 6979994
Call this function

Public Sub DisableStartup()
    Dim oShell As IWshRuntimeLibrary.IWshShell_Class, frmMsgBox As frmMessageBox
    On Error GoTo ErrDisableStartup
    Set oShell = New IWshRuntimeLibrary.IWshShell_Class
 
    oShell.RegDelete "HKLM\Software\Microsoft\Windows\CurrentVersion\Run\PMSG"
    Set oShell = Nothing
    Exit Sub
ErrDisableStartup:
    Resume Next
End Sub

Narayanan
0
 
LVL 3

Expert Comment

by:sridhar_PJ
ID: 6980004
Learning
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question