Calling a powershell script from InstallShield project - powershell

I'm having a weird problem.
I have an InstallShield project (which creates setup.exe) that contains a custom action item - calling a powershell script.
All the script does is to install 3 adobe reader updates (1 exe file and 2 msp files) on top of the already installed Adobe Reader 11.0.0.
When I'm calling the script my self - it works fine.
However, after the setup.exe finishes, it seems like only one update (the exe file) was really installed (the adobe reader version after the install is 11.00.10 which is the result of running only the exe file..).
All 3 adobe updates sit in the same folder and the powershell script first sets it location to this folder.
When running the updates manually after the installation - it also works fine and updates it to 10.00.22 (what it should be).
Any ideas why is this happening?
Here's my powershell script:
Set-Location "C:\myProject\adobeUpdates"
Start-Process .\AdbeRdr11010_en_US.exe -ArgumentList '/q /norestart /sPB /rs /msi' -WindowStyle hidden -Wait
ping 1.1.1.1 -n 1 -w 10000 # Tried to add a delay but wasn't helpful
Start-Process -FilePath “AdbeRdrUpd11021.msp” -ArgumentList '/qn' -Wait
Start-Process -FilePath “AdbeRdrUpd11022_incr.msp” -ArgumentList '/qn' -Wait
Thank you very much

Solved it, this is the working script:
Set-Location "C:\myProject\adobeUpdates"
Start-Process .\AdbeRdr11010_en_US.exe -ArgumentList '/q /norestart /sPB /rs /msi' -WindowStyle hidden -Wait
ping 1.1.1.1 -n 1 -w 10000
Start-Process .\AdbeRdrUpd11021.msp -ArgumentList '/qn' -Wait
Start-Process .\AdbeRdrUpd11022_incr.msp -ArgumentList '/qn' -Wait
I'm not sure what is the different and would love someone to explain but anyway it works just fine now.

Related

Specifying complete installation option when running msi from powershell

I am trying to automate the installation of gstreamer on windows using powershell
I have the msi file downloaded, and am installing it as shown below
PS C:\Users\Administrator> $path = "C:\Users\Administrator\Downloads\gstreamer-1.0-devel-mingw-x86_64-1.18.0.msi";
PS C:\Users\Administrator> Start-Process -Wait -FilePath $path -Argument "/qn"
However, this does not get me the complete installation, because it is only selecting the default arguments from the installer.
I need to specify for it to perform the complete installation, how can I modify my arguments? So that it selects "complete" installation and not "typical" like it does by default
These should work:
Start-Process -Wait -FilePath $path -Argument "/qn","Complete=1"
Start-Process -Wait -FilePath $path -Argument "/qn Complete=1"
I had the same problem, so I ran the Installer from power shell with and without the /qn argument and logged the process into two different files. Finally, I compared the result and I was able to find that for installing process using the UI it adds a property called INSTALLLEVEL, which is set to 1000 (don't know why this value yet). So, by adding the argument INSTALLLEVEL=1000 it installs the complete version.
Start-Process -Wait -FilePath gstreamer-1.0-mingw-x86_64-1.20.2.msi -Argument "/qn INSTALLLEVEL=1000"
I had tried below but it did not work
Start-Process -Wait -FilePath $path -Argument "/qn","Complete=1"
Start-Process -Wait -FilePath $path -Argument "/qn Complete=1"
While this is working fine for me.
Start-Process -Wait -FilePath gstreamer-1.0-mingw-x86_64-1.20.2.msi -Argument "/qn INSTALLLEVEL=1000"

Silently install multiple exe installers in one folder in PowerShell

I've been learning powershell just for a bit and i was wondering if let's say for example in "D:\installers" folder where i have let's say 15 installers(all inno Setup) it would be possible to run a silent install of all of those exes?
So far i've learnt how to run just one installer on silent which works perfectly fine. I just dont know how i would do it with multiple exes
Start-Process -Wait -FilePath 'D:\Installers\Installer.exe' -ArgumentList '/silent' -PassThru just for one installer
$installers = get-childitem "D:\Installers" -Filter "*Driver*.exe"
foreach($inst in $installers)
{
Start-Process -Wait -FilePath ($inst.FullName) -ArgumentList '/silent' -PassThru
}
Get-Childitem can be used to get the installers, and with foreach you can go through the results
You may modify the path follow yours and copy it to powershell (ensure to run as administrator).
Powershell will run them in sequence one after another.
Start-Process -FilePath 'D:\Installers\Installer1.exe' -Wait
Start-Process -FilePath 'D:\Installers\Installer2.exe' -Wait
Start-Process -FilePath 'D:\Installers\Installer3.exe' -Wait

Powershell script is not installing an exe while i try it runs through TFS Build

I have a powershell script which will install an exe. It works fine when i try it from a powershell ISE console, but it fails when i try it from TFS build step.
Note : My TFS user, agent user and triggering user are same.
Could anybody can shed some light on this issue ?
Start-Process -FilePath $installerFileName -Verb "runas" -ArgumentList $parameter -Wait
The above code is using to install the exe. $parameter is a list of custom parameters.
I am getting below error
[WixSession.GetSession][GetSessionValues]exception: Value cannot be null. Parameter name: s
What kind of exe are you trying to install? Dose that support silent installation? If UI pop up during the installation, then the agent needs to run in interactive mode.
Test on my side with below command to install/unistall the notepad++ with service mode, everyting works as expected:
start-process -FilePath "D:\Software\npp.7.5.8.Installer.x64.exe" -ArgumentList '/S' -Verb runas -Wait
And:
start-process -FilePath "C:\Program Files\Notepad++\uninstall.exe" -ArgumentList '/S' -Verb runas -Wait

Listeners installation

I am creating a PowerShell script that automates the Oracle software install. Right now everything is working correctly until I trying and setup the two listeners for the software.
When manually installing the database software you have to open a new shell and execute these two commands after the software has been installed....
netca -silent -responsefile c:\path\to\netca_listener.rsp
netca -silent -responsefile c:\path\to\netca_callout_listener.rsp
I have been trying to execute these two rsp files like so..
saps -FilePath cmd.exe -ArgumentList "/c", "netca", "-silent", "-responsefile $first_rspfile" -WindowStyle Hidden -Wait
Typically the process will spin briefly, but then will do nothing, and the response files will pop open when the process starts running.
Any clues to what might be going on?
You don't need cmd /c in PowerShell. Try this:
Start-Process -FilePath "netca.exe" `
-ArgumentList #("-silent", "-responsefile $first_rspfile") `
-WindowStyle "Hidden" -Wait

Calling another executable and capturing output

Using a PowerShell script I'm trying to execute SqlPackage.exe to update a database. The problem is that it spawns a new CMD window and I can't capture the output effectively.
Here is my script:
&$SqlPackage "/Action:Script", "/SourceFile:$($Environment.PackageFile)", "/Profile:$($Environment.PublishProfile)", "/OutputPath:$($Environment.ScriptFile)";
where SqlPackage = "SQLPackage\SqlPackage.exe";.
Strangely when I execute the script on a Windows 2008 R2 web server the output is inline with the PowerShell output, which is ideally what I want. On my Windows 7 machine it spawns a new CMD window.
How can I route the output to the PowerShell window all the time, or at least pipe to another file?
Edit
Full solution with waiting for process to finish:
$p = Start-Process $SqlPackage -ArgumentList #("/Action:Script", "/SourceFile:$($Environment.PackageFile)", "/Profile:$($Environment.PublishProfile)", "/OutputPath:$($Environment.ScriptFile)") -NoNewWindow -Wait -Passthru
$p.WaitForExit()
You should be able to get the result you are looking for if you use Start-Process with the -NoNewWindow parameter:
Start-Process $SqlPackage -ArgumentList #("/Action:Script", "/SourceFile:$($Environment.PackageFile)", "/Profile:$($Environment.PublishProfile)", "/OutputPath:$($Environment.ScriptFile)") -NoNewWindow
If you need to direct the output to a file you can also use the -RedirectStandardOutput / -RedirectStandardError parameters of Start-Process