Exit code from ClickOnce application installation

607 Views Asked by At

I found couple ways of running .application ClickOnce file. One can be to simply run this file as an executable (and let explorer do the rest) or run it as explorer does using rundll32.exe.

The thing is that I want to wait until this ClickOnce application finished installation. Waiting for exit code from Start-Process \path\to\file.application -Wait doesn't make sense because the ClickOnce app runs as a different process named dfsvc.exe. Thing is that this process usually runs in a background and does not exit after installation is complete so I can't just simply wait until it appears and then wait until it exits.

How can I programmatically check that the ClickOnce app finished installing?

1

There are 1 best solutions below

0
On

Mike,

If I understand your situation, you have several applications, one of which is a ClickOnce application, and you would like these applications to install synchronously, with each application installing fully before proceeding to the next one.

I've run into a similar situation on a few occasions with ClickOnce and have verified the installation completes with something like the below:

I select some files installed as part of the ClickOnce installation process, and check for their existence before continuing with the next application in the synchronous lineup. Usually this is done through some overarching install script or exe to monitor the install of each successive application. I'll often use a loop, checking and pausing before installing the next program in the lineup. Below is some sample code to give you an idea of what I mean:

int fileFolderCount = 0;
while (fileFolderCount != beforeInstallCount.Count() || Process.GetProcessesByName("ExeToInstall").Length != 0) 
{
    Thread.Sleep(TimeSpan.FromSeconds(15));
    fileFolderCount = new DirectoryInfo(clickOnceFilesDir)
        .GetFiles("regExpToFindClickOnceFiles", SearchOption.AllDirectories)
        .Count()        // this will recurse through the clickOnceFilesDir and pull files that match the regExpToFindClickOnceFiles. Ideally these will be the files I'm looking for as part of the install.
}

Once the install has completed, the files will be present, satisfying the first part of the loop condition, and the second condition is for those applications set to run upon install, so that they can be closed before proceeding with the next application in line for installation.

HTH