Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install ClickOnce without running

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 deployment project and create an installer, but I'd prefer to use ClickOnce.

like image 979
rjrapson Avatar asked Feb 04 '09 22:02

rjrapson


People also ask

Is ClickOnce still supported?

ClickOnce and DirectInvoke are supported out of the box for all Windows users. Users that want to disable ClickOnce support can go to edge://flags/#edge-click-once and select Disabled from the dropdown list. You'll have to Restart the browser.

How do I install prerequisites with ClickOnce application?

Click the Prerequisites button to open the Prerequisites dialog box. In the Prerequisites dialog box, make sure that the Create setup program to install prerequisite components check box is selected. In the Prerequisites list, check the components that you wish to install, and then click OK.

How do I add files to ClickOnce deployment?

To add a file to a groupClick the Publish tab. Click the Application Files button to open the Application Files dialog box. In the Application Files dialog box, select the Group field for a file that you wish to include in the new group. In the Download Group field, select a group from the drop-down list.


1 Answers

I guess you could fake it. Introduce an "IsInstalled" boolean property, defaulted to false. Then in Program.cs, change your Main() method to look like this:

[STAThread]
static void Main()
{
    Application.EnableVisualStyles();
    Application.SetCompatibleTextRenderingDefault(false);

    if (!Properties.Settings.Default.IsInstalled)
    {
        Properties.Settings.Default.IsInstalled = true;
        Properties.Settings.Default.Save();

        MessageBox.Show("Install Complete");
        return;
    }

    Application.Run(new Form1());
}

So now when the app is first installed, it checks that property and simply displays a message to the user and then quits.

If you wanted to get tricky then you could look at parsing the Activation URI for the deployment and have a URI parameter which specifies whether the program should run when it's first installed or just close silently.

like image 70
Matt Hamilton Avatar answered Oct 20 '22 01:10

Matt Hamilton