9

Is there a way to install a ClickOnce application without prompting the user at all? I'm talking about the "Run/Don't Run" that a user gets the first time he/she runs the application.

There seem to be some clues here but I believe it's about skipping the "Elevation" (UAC) and security prompts, and not the actual initial "Run/Don't Run" screen.

I can only find information about how to silently update an application that's been installed in the past, but nothing about silently installing an application for the first time.

I also found this post which seems to be related, but again, not sure if we're talking about the same user prompt...

Community
  • 1
  • 1
Joe
  • 2,496
  • 1
  • 22
  • 30

5 Answers5

9

It's possible to avoid the "Run"/"Don't Run" prompt, although you still have the issue of actually copying the files over to the user, which usually requires them launching the .application through a link. However, you may be able to launch it through a login script or something along those lines. Presumably you have solved that problem somehow as it is implied in your question that you have. The other question you linked to hovers around this but it doesn't really get you all the way.

I know you can bypass the "Run"/"Don't Run" prompt because I just did it successfully with a ClickOnce we deploy as a custom shell on kiosk machines. The key is that the ClickOnce has to be signed by a trusted publisher. Even self-signed is okay if you have the right stuff configured on the client machine.

So, have the network administrators push out a group policy that trusts the code-signing certificate that is being used to sign your application. There's information on how to do that at TechNet here: http://technet.microsoft.com/en-us/library/cc770315(v=WS.10).aspx, reproduced here briefly:

  1. Open Group Policy Management Console.

  2. Find an existing or create a new GPO to contain the certificate settings. Ensure that the GPO is associated with the domain, site, or organizational unit whose users you want affected by the policy.

  3. Right-click the GPO, and then select Edit. Group Policy Management Editor opens, and displays the current contents of the policy object.

  4. In the navigation pane, open Computer Configuration\Windows Settings\Security Settings\Public Key Policies\Trusted Publishers.

  5. Click the Action menu, and then click Import.

  6. Follow the instructions in the Certificate Import Wizard to find and import the certificate.

  7. If the certificate is self-signed, and cannot be traced back to a certificate that is in the Trusted Root Certification Authorities certificate store, then you must also copy the certificate to that store. In the navigation pane, click Trusted Root Certification Authorities, and then repeat steps 5 and 6 to install a copy of the certificate to that store.

MikeBaz - MSFT
  • 2,938
  • 4
  • 28
  • 57
7

How about creating a custom ClickOnce installer? http://msdn.microsoft.com/en-us/library/dd997001.aspx

Updated link (06 Oct 2016)

Walkthrough: Creating a Custom Installer for a ClickOnce Application

Jonnus
  • 2,988
  • 2
  • 24
  • 33
Uri Abramson
  • 6,005
  • 6
  • 40
  • 62
  • The referenced solution works great. Just in case the link goes away, it makes use of the InPlaceHostingManager class to download the manifest, assert application requirements then downloads (installs) the application. – Mike Rowley May 05 '16 at 15:18
6

In Addition to MikeBazs Answer, i'd like to provide the following "Workaround" which makes the Installation of a Click-Once-Application "non-interactive" and "almost silent" (User sees the progress-window during installation, no clicking required and/or possible)

There are a few "Issues" to consider, but if you follow this guide, the outcome should be what you need:

1.) Sign your application: Within visual Studio you can easily sign your application with your own certificate, that's no big deal.

2.) Distribute the certificate: In order to avoid the dialog, if the application should be installed, you need to distribute YOUR certificate to the following stores on any Machine (Use a GPO for that): Trusted Publishers and Trusted Root Certification Authorities

Now, users are able to install the application with a single click - no security question. But we want Zero clicks:

3.) Create a powershell script, located on a server, which invokes the setup.exe of your application, if not already installed:

$appInfo = Get-ChildItem HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall | foreach-object {Get-ItemProperty $_.PsPath}
$displayName = $appInfo | ? { $_.displayname -eq "MyApplicationName" } | select displayName

if ($displayName -eq $null){
  # MyApplicationName not installed, install! 
  Start-Process "\\server\share\MyApplication\Application\setup.exe"
}

Now, users can execute that script, only getting an installation once with no further confirmation required. But the application starts after the installation.

4.) Modify the sourcecode of your application: I used a dummy file to detect the firstrun of the application. If it IS the firstrun, (i.e. right after installation) I just shut it down again:

private void Form1_Load(object sender, EventArgs e)
    {
        //first run? That's a initial deployment, close application.
        if (!File.Exists("C:\\some\\static\\path\\notfirstrun.dat"))
        {
            File.WriteAllText("C:\\some\\static\\path\\notfirstrun.dat", "1");
            Application.Exit();
        }

Now, users can execute that script, only getting an installation once with no further confirmation required and the application does not "Auto-start" after setup.

But we want to avoid the "click" as well:

If we setup the powershell script in the Startup-Folder - it pops up, which is ugly. If we set it as Login-Script, It doesn't run in the user-context, which is required for Click-Once.

As a workaround to "this" problem, you can wrap it inside a vbs script, calling the powershell script. Note, that this is executed in the user context, so the user needs permissions to execute powershell-scripts:

Dim objShell
Set objShell=CreateObject("WScript.Shell")

strCMD="powershell.exe -sta -noProfile -NonInteractive -nologo -ExecutionPolicy Bypass -f \\server\share\scripts\install_App.ps1" 
objShell.Run strCMD,0,True

Finally, Use a GPO to deploy your vbs-script into the startup folder of any user.

All the user will see is the "installation" Progress.

In a nutshell:

  • Sign your code
  • Distribute your certificate
  • trigger the installation with a powershell script
  • wrap that powershell script inside an inivisible vbs script
  • deploy the vbs script to each users startup folder.
dognose
  • 20,360
  • 9
  • 61
  • 107
1

There is no way to install a ClickOnce application without prompting the user. if you want the user to be able to double-click on it, and it just installs without verifying with the user, don't use ClickOnce. Frankly, in my experience, only malware and packages pushed with SMS in an enterprise environment install without any prompting to the user.

RobinDotNet
  • 11,723
  • 3
  • 30
  • 33
  • Thanks Robin, it's pretty much what my researches have showed me as well. This is indeed a package that is to be deployed in my enterprise environment. It's something I want my employees to run at all time, so the silent install was preferred. – Joe Feb 25 '13 at 15:18
  • Silent Install is also helpful for network admins to write a script against to deploy to the users. – Mike May 08 '13 at 17:29
  • It doesn't seem fair to -1 my answer when it's accurate, just because you don't like the answer. – RobinDotNet Jun 22 '13 at 17:51
  • 5
    My guess is because it's inaccurate AND the accepted answer :-P – Riegardt Steyn Aug 11 '14 at 10:29
  • 4
    Here is an excellent reason for slient installs: [Chocolatey](https://chocolatey.org/). ClickOnce is a huge pain point. – jnm2 Feb 02 '16 at 15:06
  • Unfortunately, some major enterprise applications like Deltek Vision use ClickOnce for their application startup to ensure that end-users always have the lat4est version of the client-side software. I'm not promoting the practice, just shedding light on this usage. – TampaCraig Jul 02 '20 at 12:37
0

A workaround which I am using: I just built a small GUI automation script which simulates the install confirmation mouseclick. That’s how I’m deploying ClickOnce apps to a big amount of machines for a specific user profile.

ankman
  • 1
  • 1