How to execute MSI file on Github Actions (windows-latest runner) - windows

Context
I created a Github Actions workflow that generates a .msi file that I wan't to execute afterwards to test if the application is working as expected.
The workflow implementation is as below
build-windows:
runs-on: windows-latest
steps:
- uses: actions/checkout#v2.3.4
- name: Create binary from branch
run: |
choco install make
make build-windows
- name: Generate msi
shell: powershell
run: .\.github\scripts\windows\gen-win.ps1
- name: Install msi
run: |
echo "Start Msiexec"
msiexec /qn /i "file.msi" /L*vx!
echo "End Msiexec"
Basically this workflow creates the .exe file (Create binary from branch step), then use a script in powershell that generates the .msi file (Generate msi step), and finally try to install the .msi file (Install msi step).
Issue
The problem occurs on the Install msi step, the runner logs only returns:
Start Msiexec
End Msiexec
... without showing any log, or creating the directories and files as the installation should do on the $HOME directory.
What I tried
Using the default shell for windows-latest runner (which is cmdlet), I tried to run those commands in the workflow without success, using "file.msi" or "path/to/file.msi":
msiexec /i "file.msi"
msiexec /qn /i "file.msi"
msiexec /qn /i "file.msi" /L*vx!
I'm not very familiar with the windows operating system, but for what I searched online, this msiexec command should work.
I also tried to install the .msi file generated manually on a windows 10 computer using those commands with success (so the generated .msi file is valid and working locally). However, it opens another prompt window automatically showing the installation and setup logs (it's not in the same terminal window) and I imagine this may not happen on Github Actions.
Question
➡️ How can I install this application from the .msi file through a command line on the windows-latest runner?

After asking the same thing on the Github Community forum, I got the following answer from #Simran-B (Github Advisory Council Member):
msiexec doesn’t seem to log anything to a terminal. If your MSI does
(even if in a separate window), then it must be something that is
specific to that MSI…
What msiexec supports is to log to a file. Based on Is there anyway
to get msiexec to echo to stdout instead of logging to a file - Server
Fault,
I successfully ran the following PowerShell script (using a Blender
MSI as a test):
$file = "file.msi"
$log = "install.log"
$procMain = Start-Process "msiexec" "/i `"$file`" /qn /l*! `"$log`"" -NoNewWindow -PassThru
$procLog = Start-Process "powershell" "Get-Content -Path `"$log`" -Wait" -NoNewWindow -PassThru
$procMain.WaitForExit()
$procLog.Kill()
I can’t recommend /l*vx!, because the forced flush for every log
line makes things slow and the verbose output with additional
debugging information can produce thousands of lines. Alternatively,
you could log everything to a file without flushing, wait for
msiexec to exit, and then print the file contents to the console in
one go, which should be significantly faster (but you lose live
logging).
If I remember correctly, GitHub-hosted runners use elevated
permissions by default. In my local test, I had to run the above
script from an elevated PowerShell because the MSI tried to install to
C:\Program Files\, which is not writable unless you have elevated
permissions, and that made the installation fail without obvious log
entry. If there’s something wrong with the .msi path, you may get an
exit code of 1619 ($procMain.ExitCode), which is also not very
intuitive. Another possible reason for nothing getting installed (at
least apparently) can be that you don’t actually wait for msiexec to
finish - the command immediately returns and the installation process
runs in the background. You can use Start-Process with the -Wait
option or get the handle with -PassThru and call .WaitForExit() on
it to wait until it is done.
It worked for me! With those commands, I could execute the .msi file to install the software, then use it afterwards in my github actions workflow to perform my tests!

Related

Add date to installer log file

I'm building an installer using advanced installer and have run into a problem trying to add dates into the log file. I tried a command using cmd which worked, however when I added it to the MSI commandline all the date values came out as blank. Below is the parameters I pass for the MSI
/L*V "C:\Log_%date:~4,2%.%date:~7,2%.%date:~10,4%-%time:~0,2%.%time:~3,2%.%time:~6,2%.log"
We are trying to make the log be Log_04.05.2019-15.03.45.log instead of Log.log since the logs get overwritten when uninstall happens or on a retry of an installation..
Advanced Installer: Sorry, I see that I must have misunderstood. You are trying to set the log file name from within Advanced
Installer. Will have a quick look. Where do you specify this command line in the tool? Please note that setting the logging policy for "Global Logging" will ensure unique log file names and that every MSI operation is logged in TMP.
Clarification: So it looks like you don't want to write to the log, but to control the file name of the log file itself?
PowerShell: I find batch files clunky with regards to stuff like this. Can you invoke the installation via Powershell? I don't really use PowerShell, but seeing as it can use .NET, maybe a simple conversion of this C# call would do the trick?
You want something like: "Log_04.05.2019-15.03.45.log", so you could perhaps try this in C#:
Console.WriteLine("Log_" + DateTime.Now.ToString("dd.MM.yyyy-HH.mm.ss") + ".log");
Here is a blog on using PowerShell with Windows Installer, see towards the bottom for this PowerShell snippet (again, I do not use PowerShell for this purpose):
$DataStamp = get-date -Format yyyyMMddTHHmmss
$logFile = '{0}-{1}.log' -f $file.fullname,$DataStamp
$MSIArguments = #(
"/i"
('"{0}"' -f $file.fullname)
"/qn"
"/norestart"
"/L*v"
$logFile
)
Start-Process "msiexec.exe" -ArgumentList $MSIArguments -Wait -NoNewWindow
Maybe also have a read about the Windows Installer PowerShell
Module (Heath Stewart) as linked to in this general purpose
answer:
How can I use powershell to run through an installer?.
Special-purpose PowerShell Module making Windows Installer operations
less clunky.
Some Links:
Various MSI logging methods: Enable installation logs for MSI installer without any command line arguments
Windows Installer Logging

Running MSIEXEC in a NSIS script with installer switches

I'm trying to build an NSIS installer and package it with necessary drivers (MSI files from the vendor). Eventually, I'd like to install these drivers silently in the backgroud. However, I cannot seem to get it working properly.
In my NSIS script, I have the following:
ExecWait 'msiexec /i "$INSTDIR\Flash.msi INSTALLDIR="$INSTDIR\Drivers\Flash""'
It seems to execute; if I remove the INSTALLDIR switch from the above snippet, it'll run the driver installation as expected. But when I leave it in, I'm instead greeted by the following window
However, running the following directly in Powershell does exactly what I want, sets the install directory appropriately, as expected:
.\Flash.msi INSTALLDIR=".\Drivers\Flash\"
I'm guessing it's a silly quotation-mark mismatch somewhere, but I've tried so many already and I get the same results.
Your doublequote for the .msi path is closed too late.
Use
ExecWait 'msiexec /i "$INSTDIR\Flash.msi" INSTALLDIR="$INSTDIR\Drivers\Flash"'
Have you tried the following:
ExecWait 'msiexec /i "$INSTDIR\Flash.msi INSTALLDIR=$\"$INSTDIR\Drivers\Flash$\""'
or
ExecWait 'msiexec /i "$INSTDIR\Flash.msi INSTALLDIR=$\"$\"$INSTDIR\Drivers\Flash$\"$\""'
Reference: http://nsis.sourceforge.net/Docs/Chapter4.html and take a look at the Strings section under 4.1 Script File Format.
Updated with extra escaped quotes.

InstallShield silent install CR Runtime 13.0.17

Hi, I create a Setup with Installshield 2015. my setup has a prerequisites for reporting viewer so i want to install CR_Runtime13.0.17.msi silently. for this situation we want a command to start the cr_runtime setup silent, after many searches on the net i found this command.
msiexec /i IsSetupPrerequisites\CR_Runtime13\CR_Runtime13.0.17.msi /qb /norestart
when i use this command on Cmd it works well and setup is begins silently with progress bar but when i use this command on installshield, it show me an error and a help every time.
please help me to create a command for installshield to install cr_runtime13.0.17 silently.
at the end i Attached installshield command page and my help to this Question.
Many Thanks to all
The Specify the command line for the application value is really just the arguments. From Specifying Command-Line Parameters for an InstallShield Prerequisite:
Type any valid parameters for the file that is selected in the Specify the application you wish to launch list. Do not include the name of the file in this box.
Remove your inclusion of msiexec and an attempted relative path to the msi, leaving you with just /qb /norestart, and you should avoid the msiexec error. If that one still gives you problems, consider replacing /norestart with REBOOT=ReallySuppress.
I had to create a prerequisite for .net 4.6.1 and it worked silently when I had only /q /norestart in the command line and command line for silent mode.(instead of /qb /norestart)

msiexec does not pass parameters from the command line

I was trying to use MSI installer to install this file myInstaller.msi and also pass the value "192.168.2.1" to IPADDRESS, which is mandatory on the process of installation. However, it comes up an error message "install failed". I checked on Windows, the application is installed, but it's not on Windows Services, where it is supposed to be.
msiexec /i myInstaller.msi IPADDRESS=192.168.2.1
I also have read this link msiexec does not pass parameters to custom action. There is comment saying that installing ORCA and then editing the MSI file, it should work, however, after I have deleted cut row containing CustomTextC_SetProperty_EDIT1, and then saved the MSI file, it seems it's broken, it can not even run, the file is damaged.
Any help for this? I have been working almost 2 days trying to work it out, but can't. :-(
I'll try to answer with a potential quick fix rather than a long explanation:
Open an unharmed copy of the MSI file with Orca
Add to the Property table:
Property column: IPADDRESS Value column: 192.168.2.1
Then add IPADDRESS to the delimited list in SecureCustomProperties. See image below
Save and close, and run the MSI
Open an elevated cmd.exe prompt (search in start menu for cmd.exe, right click and run as administrator)
Install with command line (modify with your own paths): msiexec.exe /I "myInstaller.msi" /QN /L*V "C:\msilog.log"
Check results, and report here what you find. Most likely there is something else wrong, but this will bypass most other error sources.
I do not recommend this approach as anything but a quick test.

Installshield Silent Uninstall not working at Command Line

We have an older app from 2006 we'd like to uninstall at the command line using group policy, but I can't get a silent uninstall to work.
This works. Of course I need to click Next to uninstall:
"C:\App\Setup.exe" /uninst
But this does not. I see an hourglass for a couple seconds but the app is not uninstalled.
"C:\App\Setup.exe" /uninst /s
I also unsuccessfully tried some VBScripts. They find the app listed but the uninstall fails. I'm not too familiar with how this process is supposed to work.
You need to create first an ISS response file to silently remove your application,
Create response file :
C:\App\Setup.exe /r /f1c:\app\uninstall1.iss
you will be asked to uninstall, .... and perhaps reply the others windows.
Then your application would be uninstalled and you get a new response file c:\app\uninstall1.iss
Next, if you want to remove silently this application on another computer :
launch : C:\App\Setup.exe" /s /f1c:\app\uninstall1.iss
For more information see:
http://www.itninja.com/blog/view/installshield-setup-silent-installation-switches
Best Regards,
Stéphane
Try this, with the original setup.exe version that was used to install
"C:\App\Setup.exe" /x /s /v/qn
I've been struggling with the silent uninstaller for a while, and finally came to a solution that works for me in most cases, both for InstallShield v6 and v7.
1. First (as it was mentioned above), you have to generate an InstallShield Response file (e.g. uninstall.iss). In order to do that you have to launch your setup.exe with parameters:
> setup.exe -x -r -f1"C:\Your\Installer\Location\uninstall.iss"
This will go through the normal uninstall wizard and generate a Response file for you: uninstall.iss
2. Then, before trying your silent uninstaller, I guess, you should re-install the software.
3. And finally, run your silent uninstaller playing back the recently generated Response file:
> setup.exe -x -s -l0x9 -ARP -f1"C:\Your\Installer\Location\uninstall.iss"
That's it.
Now, a few important notes:
Note 1: I'm working with a 3-rd party installation package that I didn't build myself.
Note 2: I use dashes (-) instead of slashes (/) to define parameters. For some reason it doesn't work with slashes for me. Weird but true.
Note 3: The -ARP and -l switches are required for some installation packages to manage the software removal from the Add/Remove Programs list and to preset the default input language accordingly.
Successful silent uninstallation is all about the correct parameters!
So keep exploring, the correct parameters vary depending on a specific package and installer version.
I hope my input was helpful.
Try
Format: Setup.exe M{Your Product GUID} /s /f1[Full path]\*.iss for creating the ISS file for uninstallation.
From Stephanie's sample, I think it's missing the GUID.
There's a good link at the developer's site # Creating the Response File.
Try it out n tell us,
Tommy Kwee
I struggled with this for a long time so posting it here in case anybody else stumbles upon it.
If you happen to have an installer which uses the legacy Package-For-The-Web format then you need to use the parameter -a to pass additional parameters to the extracted setup file.
Record (un)installation files (click through the installer manually):
.\DWG2PDF2019.exe -a /r /f1"c:\app\dwg2019_install.iss"
.\DWG2PDF2019.exe -a /r /f1"c:\app\dwg2019_uninstall.iss"
Silently (un)install:
.\DWG2PDF2019.exe -s -a /s /f1"c:\app\dwg2019_install.iss"
.\DWG2PDF2019.exe -s -a /s /f1"c:\app\dwg2019_uninstall.iss"
Source: https://help.hcltechsw.com/caa/3.0/topics/appacc_silent_install_t.html
There's another way to uninstall an app by searching for it in the Registry, and using the UninstallString (this sample code uses powershell on windows 10):
# Get all installed apps from Registry
$Apps = #()
$Apps += Get-ItemProperty "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*" # 32 Bit
$Apps += Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*" # 64 Bit
# Uninstall My App
$my_app = $Apps | Where-Object{$_.DisplayName -eq "The Name Of My App"}
$uninstall_string = " /C " + $my_app.UninstallString+' /S'
Start-Process -FilePath "cmd.exe" -ArgumentList $uninstall_string -Wait
if you don't know the exact full display name of your app, you can print the "Apps" array to a file, and search there:
$Apps | Out-File C:\filename.txt
I was working on a silent uninstall of an InstallShield installer and was running into similar issues. What was posted here did not work or help. After lots and lots of trial and error I did find that for some reason when I used the -uninst option for both the creating the response file and running the silent uninstall I had success. In case anyone runs into a similiar issue and stumbles upon this thread I wanted to share. I am not sure why but adding -uninst did change the contents of the response file.
In my example creating response file: "C:\Program Files (x86)\InstallShield Installation Information\{0D20ACF2-CEE1-4523-BFCF-389BC4CC81FB}\setup.exe" -runfromtemp -l0x0409 -removeonly -uninst -r -f1"c:\uninstall.iss"
Then I could finally get the silent uninstall to function as expected: "C:\Program Files (x86)\InstallShield Installation Information\{0D20ACF2-CEE1-4523-BFCF-389BC4CC81FB}\setup.exe" -runfromtemp -l0x0409 -removeonly -uninst -s -f1"c:\uninstall.iss"

Resources