I have created installer(exe) using clickonce which provides GUI for installing my application.
Now I wanted to make this installer to run silently from commandline by taking some of the arguments from command window. Arguments may be like database server name, user id and password etc.
This silent installer should also take care of pre-requisites that I have mentioned for GUI based installer. There is .Net Framework v4.7.1, VC++ 2017 and windows installer v4.5 are my pre-requisites required to be installed onto the target machine if they are not available.
I have tried to read arguments from program.cs Main method, I am now able to fetch argument and able to run installer command line without issue on the machine where my pre-requisites are installed already.
There I have no clue on running .net fx, VC++ and Windows installer from silent installer. Because my installer is not launched because of no prior .Net fx is installed there.
My expectation is to run .Net fx, VC++ and Windows installer before running my installer from commandline window.
Inno Setup (https://jrsoftware.org/isinfo.php) has support for "Running other programs before, during or after install." so you can launch other installers and wait, here is how to install MSI files (you can download and distribute them with your installer):
https://jrsoftware.org/iskb.php?msi
Here are the install parameters that are required for silent installation (you can make a SilentSetup.bat file and execute that):
/SILENT Runs the installer in silent mode (The progress window is displayed)
/VERYSILENT Very silent mode. No windows are displayed.
/SUPPRESSMSGBOXES Suppress message boxes. Only has an effect when combined with '/SILENT' and '/VERYSILENT'.
/NOCANCEL Disables cancelling the installation process.
/NORESTART Prevents installer from restarting the system even if it's necessary.
/DIR="x:\dirname" Overrides the default install directory.
I have used VS Setup projects (no longer supported out of the box), Install Shield (for advanced dialogs during install), ClickOnce (at my employer, which is a pain and can fail by no fault of your code but windows config) and Inno Setup.
Unless you need features that Inno Setup doesn't have, I recommend you go with it, you could also perform custom tasks with either scripting or executing an Exe:
https://jrsoftware.org/iskb.php?custom
Related
We are going to release an application developed using C# and now recently we faced a problem building set up application using Advanced Installer 15.6.
To put it in more detail we are going to one to install .NET Framework 4.6.1 in silent mode (with no window).
We tried to find the solution for several hours and also asked Advanced Installer team, but haven't find or receive any answer.
Tried as followings.
/q
/quiet
...
Hope to receive quick answers.
Do you launch the setup package elevated, for instance by using Run as admin , or as a child process within an elevated process? If the setup package is not launched elevated the prerequisite installer will fail to install silently from what I know.
I'm using the Visual Studio Installer Projects extension to build the MSI-installer for my application. However, my application is meant to be running at all times, and if it's open when the user is installing a new version of my software, the open files are not overwritten, and very little to nothing is actually updated (although there are no installer-errors).
I've found that using the installer project's "Custom Actions" to run a script that closes the application doesn't help, as none of the actions are called before the files are replaced.
Is there a good way to make sure the open/locked files gets terminated before the files are supposed to be overwritten?
We had this problem, and the solution we came up with was to create two apps; the user app and an updater app. The MSI installs both. Each app checks if the other needs updating and, if it does, closes the other app, downloads the other app's updater, runs it, then relaunches the other app. Additionally, each app monitors if the other app is running and, if it isn't, launches it.
It would be useful to know more about your application and how you are doing the upgrade because:
You will normally see a FilesInUse dialog saying that files are in use, prompting the user to shut them down, but not if the install is silent.
Visual Studio setups have no built-in support for shutting down and restarting services, so if your app is a service you'll need extra work.
Files that actually do need to be replaced will prompt the user for a reboot (if they are not previously shut down) in order to replace them at reboot time.
So if you're not seeing reboot requests or FilesInUse dialogs in a UI install then something else is going on. So you need to be sure that:
a. You are really doing an upgrade where the version of the setup project has been incremented, the UpgradeCode is the same (and the ProductCode changes when you increment the setup project's version). Your symptoms could be the result of the upgrade not working and you're seeing just a repair.
b. The definition of "new version" is that you have an upgrade as in a., AND, the file versions of the binaries have been incremented. The default overwrite rules for installs require incremented file versions, so if they haven't been incremented you'll see no updates, and Windows will not attempt to show FilesInUse dialogs or reboot because there are no files that need replacing.
This isn't a solution to the problem, but rather another solution; the one requiring the least work in the end.
I ended up not using 'Visual Studio Installer Projects' for my installer. Instead I looked to Advanced Installer, which just works with no issues. Things like this is taken into account, and custom actions allow for more options.
If your project is open source, you can write to them about a free open source "professional" license, equal to their "professional" plan, which is normally $399 (onetime purchase).
REBOOT: How are you installing this MSI? What command line? If you set REBOOT=ReallySuppress on the command line, you will not be prompted for a reboot even if one is required to complete the installation of the product.
msiexec.exe /i MySetup.msi /QN REBOOT=ReallySuppress
If you are using a distribution system I suppose suppressing reboot prompts could be standard behavior. Then your product files should be put in place after a reboot (PendingFileRenameOperations or perhaps some newer mechanism).
It is also possible that Visual Studio Installer Projects do something strange that I am not aware of.
Log: I would try to create a good log file for the install, to determine what is going on:
msiexec.exe /i C:\Path\Your.msi /L*v C:\Your.log
Log All MSIs: Personally I like to enable logging for all MSI installations - as described in the "Globally for all setups on a machine" section in the above link.
Interpreting an MSI log: interpreting a log file can be challenging sometimes. Here is an answer with some links to help with this.
Reboot Manager: Reboot management is a very complex topic, and Windows features functionality - in the form of the restart manager feature - to try to minimize the need for reboots, by instead shutting down and restarting applications as part of an installation in an "auto-magical" fashion (application listens for messages and shuts itself down gracefully when told to, and the system may restart the application after the install - if configured to do so).
Updating your application to comply with the restart manager is the only real fix for such problems that you see, in my opinon.
The section "Restart Manager" in this question tries to summarize how to implement such support (maybe just read the yellow section a bit down the page).
The Advanced Installer guys have a very nice, technical article about this:
How do I add support for Windows Restart Manager to my application? Also linked to in the link directly above - still worth a direct link here I think.
According to below link
https://social.msdn.microsoft.com/Forums/windows/en-US/0b40b367-3341-43d8-b82e-1ace546969f8/how-can-installation-stop-and-restart-existing-service-?forum=winformssetup
"There is no good support in VS installs to stop and start services. During install, the issue is that custom actions run after everything is installed so it's too late to stop a service that you are upgrading or replacing. Yes, they have names like "BeforeInstall" but they really are not before the install."
I have followed this blog for deploying my WPF application. I used windows installer technology classic setup project template in Visual Studio 2015.
I am using windows installer instead of ClickOnce deployment because I need to choose my own installation path and custom wizard UI.
But there is not information regarding how to update my application when I use windows installer to deploy my application. How can I update my app after once it was installed in clients machine? Are there different possible ways to achieve this?
It would be helpful if anyone can provide the resources or suggest any practical approaches that I can use to update my WPF app.
In Visual Studio setups you use the RemovePreviousVersions project property. This should help:
https://www.simple-talk.com/dotnet/visual-studio/updates-to-setup-projects/
Basically just increment the setup project version, accept the changes, keep UpgradeCode the same, set RemovePreviousVersions to true.
The project's properties window is shown when you select the setup project in Solution Explorer and use F4, or View=>Properties Window, NOT property pages.
You'll also need to increment the file versions of files you wish to be updated.
If you want to do it silently, use the msiexec command line options that include /q, such as msiexec /I [path to your new msi] /q
However if your install requires elevation it will fail because silent really means silent, so the usual request for elevation will not be shown.
I'm trying to make a silent install of an .exe that I'm downloading.
The download method is irrelevant since it has nothing to do with the install.
However, when it's done downloading and I've started the process, instead of installing it the way I want it (Not having to press the next button) it just opens the UAC asking for administrative privileges. When I press YES it opens the .exe and I have to install it manually.
Is there a way to install it the way I want to?
Process process = new Process();
process.StartInfo.FileName = #"C:\PATH\Setup.exe";
process.StartInfo.Arguments = "/quiet";
process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
process.Start();
process.WaitForExit();
Silent installation of an exe is not easy. The easiest way is using an msi package to achieve this. Therefore you have to extract the msi from the exe and call it with one of these parameters:
full UI: /qf (this is the default parameter)
reduced UI: /qr (the user interface does not show any wizard dialogs)
basic UI: /qb, /passive (only a progress bar will be shown during the
installation)
no UI: /qn, /quiet (no UI will be showed during the installation)
On Windows Vista and above, in order the install the package silently the installation package should run elevated. Therefore the parent process calling the setup.exe have to run as administrator.
If you want to install an exe silently then there is lot more that you have to do. But it depends what type of installation package you are trying to install. Find out what was the installer software that the package was created with, then look up the documentation specified to the package. You need to look for the command line arguments within the documentation that allows to run the exe silently, if it is possible. As well as you have to find out whether the package install as per user or as per machine, because various permissions determine the elevation type.
If you can't package the origional installer into an MSI, then you could always take a look at Auto IT (https://www.autoitscript.com/site/autoit/)
AutoIt v3 is a freeware BASIC-like scripting language designed for automating the Windows GUI and general scripting. It uses a combination of simulated keystrokes, mouse movement and window/control manipulation in order to automate tasks in a way not possible or reliable with other languages (e.g. VBScript and SendKeys). AutoIt is also very small, self-contained and will run on all versions of Windows out-of-the-box with no annoying “runtimes” required!
Using this you could play around and get the 'Next' button to be clicked automatically in essence, achieving your goal.
If your installer is InstallShield you can use this command: setup.exe /s /v/qb for silent install with basic MSI UI or setup.exe /s /v/qn for silent installation without any UI.
Take a look at this question https://stackoverflow.com/a/39047467/5675763 It may help.
I have created a c# 4.0 windows service. I have created an installer project (.msi) for it which installs the service to a particular folder.
To automate the process fully, I would like to install the service as part of the custom actions I have for my installer.
How can I code my custom actions to install or when uninstalling the msi, uninstall the windows service?
You can use the ServiceInstaller class. A quick solution would be to find installutil tool and execute it against your Service.exe, but you have to capture the output to see whether the installation succeeded or not and you don't have much control over Install, Commit, Rollback, and Uninstall phases.
Simple answer: don't. The proper way is to install it using the MSI database itself, i.e. ServiceInstall and ServiceControl tables. Every single "convenient" IDE for MSI creation and also WiX come with primitives to make use of this builtin facility.
The very reason that this is best practice, just like including the COM registration in your MSI instead of calling DllRegisterServer of the COM (DLL) to register is that your application may be defunct at the time the user attempts to remove it.
The database actions can still be executed even by a newer Windows Installer, say after an upgrade of Windows itself, while your code may refuse to run or may not run for other reasons.