.NET 制作卸载程序

创建一个没有任何窗体的应用程序

修改Program.cs中的代码:

static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            if (MessageBox.Show("确定要卸载本程序吗?", "确定", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
            {
                string sysroot = System.Environment.SystemDirectory;
                Process Uninstall = new Process();
                Uninstall.StartInfo.FileName = sysroot + "//msiexec.exe";
                Uninstall.StartInfo.Arguments = "/x {E337BA2A-F7F4-4F56-A2CE-BCA620BCC42B} /qb";
                Uninstall.Start();
            }
        }
    }



红色部分是你制作的安装包的ProductCode


你可能感兴趣的:(.net,String,Class)