Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6717521
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:51:45+00:00 2026-05-26T08:51:45+00:00

I have created a sample application named (WindowStartup.EXE) that display the Computer name, OS

  • 0

I have created a sample application named (WindowStartup.EXE) that display the Computer name, OS version and user logged in. This application is also consist of auto run behavior upon starting the machine. Please see below codes. Code is written on C#

private void InfoWindow_Load(object sender, EventArgs e)
{
    lblMachineName.Text = Environment.MachineName.ToString();
    lblOSVersion.Text = Environment.OSVersion.ToString();
    lblUserlogged.Text = Environment.UserName.ToString();
    this.Top = Screen.PrimaryScreen.WorkingArea.Bottom - this.Height;
    this.Left = Screen.PrimaryScreen.WorkingArea.Right - this.Width;

    if (StartUp()) StartUpSystem();
}

private bool StartUp()
{
    bool retVal = false;
    if (File.Exists(Application.StartupPath + "\\SystemFile.txt"))
    {
        //read text file if content is true
        Stream file = new FileStream(Application.StartupPath + "\\SystemFile.txt", FileMode.Open, FileAccess.Read);
        StreamReader reader = new StreamReader(file);
        string content = reader.ReadToEnd();
        if (content == "true") retVal = true;
    }
    return retVal;
}

private void StartUpSystem()
{
    RegistryKey regApp = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
    if (IsStartupItem())
    {
        //--> Add the value in the registry so that the application runs at startup
        regApp.SetValue("WindowStartup.EXE", Application.ExecutablePath.ToString()); 

    }
}

private bool IsStartupItem()
{
    // The path to the key where Windows looks for startup applications
    RegistryKey regApp = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);

    if (regApp.GetValue("WindowStartup.EXE") == null)
        // The value doesn't exist, the application is not set to run at startup
        return false;
    else
        // The value exists, the application is set to run at startup
        return true;
}

After creating an installer and installing it in my machine, it runs without an error. But upon uninstalling this sample application, it still pop-up every time i start my machine.

I’ll try the below code to remove the value from the registry but it seems that it’s not working

private void StartUpSystem()
{
    RegistryKey regApp = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
    if (!IsStartupItem())
    {
        //--> Remove the value from the registry so that the application doesn't start
        regApp.DeleteValue("WindowStartup.EXE", false); 

    }
}

Can anyone help me on how can I remove it programmatically?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T08:51:46+00:00Added an answer on May 26, 2026 at 8:51 am
        private void DeleteRegistryKey()
        {
            using (RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true))
            {
                if (null != key && IsStartupItem())
                {
                    key.DeleteValue("MyApp");
                }
            }
        }
    
        private bool IsStartupItem()
        {
            // The path to the key where Windows looks for startup applications
            RegistryKey regApp = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run", true);
    
            if (regApp.GetValue("MyApp") == null)
                // The value doesn't exist, the application is not set to run at startup
                return false;
            else
                // The value exists, the application is set to run at startup
                return true;
        }
    
        private static void SetRegistry(string path)
        {
            if (!IsStartupItem())
            {
                Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run", "MyApp", path);
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a sample java socket application. I used Socket s = new
I created a simple ASP.NET MVC version 1.0 application. I have a ProductController which
I have created a sample silverlight application and trying to populated DataGrid with Data
I have an application that 1) loads an xml, 2) uses a repeater (named
i am new to android application.I have created two sample applications as Oneproject,Twoproject.when i
I am creating an application that saves GPS coordinates; I have created a button
I have created a sample MVC3 application for BookShop. I have a create action.
I have created a simple blog application with Ruby on Rails. The applications consists
I have created a simple win 32 application..in which it has a textbox and
I have a requirement to create a simple windows forms application that allows an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.