If we want our .exe applicationĀ written in c# to be launched while windows starts..then here is the code ..
firstly we have to use a namespace
using System.Microsoft.win32
and the code is as follows….
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.Win32;
namespace RunAtStartup
{
public partial class frmStartup : Form
{
// The path to the key where Windows looks for startup applications
RegistryKey rkApp = Registry.CurrentUser.OpenSubKey(“SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run”, true);
private void btnOk_Click(object sender, EventArgs e)
{
// Add the value in the registry so that the application runs at startup
rkApp.SetValue(“MyApp”, Application.ExecutablePath.ToString());
}
}
}