Install ClickOnce without running

前端 未结 4 466
小蘑菇
小蘑菇 2020-12-06 17:52

When you install a ClickOnce application, the program runs after the install. Is it possible to install without running?

I know I can use a setup and deploy

4条回答
  •  旧时难觅i
    2020-12-06 18:25

    You can do this by editing the application manifest in Mage. There is a checkbox to stop the application running after installation.

    If you are not comfortable editing a manifest manually or with Mage then you can use the built-in deployment class to check whether this is the first time the application has run.

    using System.Deployment.Application
    
    [STAThread]
    static void Main()
    {
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
    
        if (ApplicationDeployment.CurrentDeployment.IsFirstRun)
        {
            MessageBox.Show("Install Complete");
            return;
        }
    
        Application.Run(new Form1());
    }
    

提交回复
热议问题