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.