Running a program on windows startup and on logging off or shutting down

Posted on 2005-04-23
Last Modified: 2010-04-17
i have wrote a program that i want to run first when user logsin and then when it shuts down or logs off.....i am using windows xp with visual
please guide me.
Question by:neutrongenious
    LVL 25

    Accepted Solution

    For logon, just add a String Value to this Registry Key: HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
    The String Value's value should be the location of your program.

    For the logoff/shutdown, see here:

    LVL 37

    Expert Comment

    by:Harisha M G
    Hi neutrongenious,

    You should write a key in the registry


    Dim regKey As RegistryKey
    Dim ver As Decimal
    regKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", True)
    regKey.SetValue("YourAppName", "C:\FolderName\YourAppExe.EXE")

    For details... look at

    LVL 37

    Expert Comment

    by:Harisha M G
        Dim ver As Decimal
    is not required !!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Here we come across an interesting topic of coding guidelines while designing automation test scripts. The scope of this article will not be limited to QTP but to an overall extent of using VB Scripting for automation projects. Introduction Now…
    Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
    In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
    In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

    779 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

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now