Question

Worklet to first Uninstall Microsoft Office 2019 then install MS Office 2021

  • 18 March 2024
  • 8 replies
  • 64 views

Badge

Hi,

 

I tried to use the PS script to directly install MS Office 2021 to the client machine that is currently having the MS Office 2019. I’m getting the error message saying “ You have to uninstall MS Office 2019 ….” 

I’m not sure if possible, but I’m looking for the worklet with script that first to Uninstall Microsoft Office 2019 Pro then install MS Office 2021 Plus after that...

Please help if any one got this procedure done successfully.

Thank you!


8 replies

Userlevel 1
Badge

We use the <RemoveMSI /> in our xml 

is this option in your configuration.xml file? 

Remove existing MSI versions of Office when upgrading to Microsoft 365 Apps

Badge

Hi Maalvarez,

This is my xml. I did use it after searching thru google for suggestions, but it doesn’t work.

<Configuration ID=" ">
  <Info Description="" />
  <Add OfficeClientEdition="64" Channel="PerpetualVL2021" SourcePath="P:\MS OFFICE 2021" AllowCdnFallback="TRUE">
    <Product ID="ProPlus2021Volume" PIDKEY=" ">
      <Language ID="en-us" />
      <ExcludeApp ID="Lync" />
      <ExcludeApp ID="OneDrive" />
      <ExcludeApp ID="OneNote" />
      <ExcludeApp ID="Publisher" />
    </Product>
  </Add>
  <Property Name="SharedComputerLicensing" Value="0" />
  <Property Name="FORCEAPPSHUTDOWN" Value="FALSE" />
  <Property Name="DeviceBasedLicensing" Value="0" />
  <Property Name="SCLCacheOverride" Value="0" />
  <Property Name="AUTOACTIVATE" Value="1" />
  <Updates Enabled="TRUE" />
 

<RemoveMSI />
  
  </AppSettings>
  <Display Level="Full" AcceptEULA="TRUE" />
</Configuration>

Badge

Can you share your XML file if it works for you? Thanks!

Userlevel 1
Badge

Sure thing, we’re running office 2019 I haven’t built a deployment for 2021 yet, let me work on that in a test environment and I’ll let you know how it goes 

Badge

Thank you, pls keep me posted.

Userlevel 1
Badge

Ahh..sorry I compleatly misread your post…

The <RemoveMSI /> is for msi installs of office but office 2019 is C2R 

so what I did was pass the Remove all in the configuration file and it worked, it uninstalled office 2019 and installed 2021 

It also removed Project plus and visio so if you have those instaleld in your environment don’t forget to add them to your configuration.xml file. 

Here is what I added to remove office 2019 

  <Remove All="TRUE">
<Product ID="PerpetualVL2019" >
<Language ID="en-us" />
</Product>
</Remove>

I used your same xml here is the complete file 

<Configuration ID=" ">
<Info Description="" />
<Add OfficeClientEdition="64" Channel="PerpetualVL2021" SourcePath="P:\MS OFFICE 2021" AllowCdnFallback="TRUE">
<Product ID="ProPlus2021Volume" PIDKEY=" ">
<Language ID="en-us" />
<ExcludeApp ID="Lync" />
<ExcludeApp ID="OneDrive" />
<ExcludeApp ID="OneNote" />
<ExcludeApp ID="Publisher" />
</Product>
</Add>
<Property Name="SharedComputerLicensing" Value="0" />
<Property Name="FORCEAPPSHUTDOWN" Value="FALSE" />
<Property Name="DeviceBasedLicensing" Value="0" />
<Property Name="SCLCacheOverride" Value="0" />
<Property Name="AUTOACTIVATE" Value="1" />
<Updates Enabled="TRUE" />
<Remove All="TRUE">
<Product ID="PerpetualVL2019" >
<Language ID="en-us" />
</Product>
</Remove>

<RemoveMSI />

</AppSettings>
<Display Level="Full" AcceptEULA="TRUE" />
</Configuration>

let me know if this helps!

Badge

I modified mine a bit and it works. 

I noticed, if you have MSOffice 2021 installed after remove the 2019, and schedule to run the policy frequently,  then anytime the policy runs, it will automatically close the app w/t saving work while the end user having it open. I would think about we should have the validation check: When run the policy, it would check if the client machine already has MSOffice 2021 installed, then skip it. If not, then install…

I don’t have any source to come up with the script, but found in the root dir, there’s a txt file that I can use for the validation. Just want to share, but if you have any better script, pls share as well.

worklet

  • Evaluation Code:

    # Check if txt file there, then skip
    if (Get-Item -Path "C:\Program Files\Microsoft Office\root\Office16\1033\ClientLangPack2021_eula.txt"
    {

        Exit 0

    else 

        Exit

    }

Remediation Code:

 

Start-Transcript -Verbose -Path "c:\MSOffice2021\msoffice2021.log"

Copy-Item ConfigurationLocal2021.bat -Destination "c:\MSOffice2021\ConfigurationLocal2021.bat" -Verbose

Copy-Item ConfigurationLocal2021.xml -Destination "c:\MSOffice2021\ConfigurationLocal2021.xml" -Verbose

Copy-Item setup.exe -Destination "c:\MSOffice2021\setup.exe" -Verbose

$checkfile = "C:\Program Files\Microsoft Office\root\Office16\1033\ClientLangPack2021_eula.txt"

 

if (Get-Item $checkfile -Verbose) {

    Write-Output "Microsoft Office 2021 is already installed. Skipping..."

    Write-Output "Exit Code: $LASTEXITCODE"

    exit

 

} else {


    Write-Output "Microsoft Office 2021 not installed, installing..."  

    

WindowStyle Hidden -Wait -Passthru).ExitCode

Start-Process -FilePath "C:\MSOffice2021\ConfigurationLocal2021.bat" -WindowStyle Hidden -Wait -Passthru -Verbose

 

Write-Output "Office 2021 is installed"

}

Stop-Transcript

 

 

 

Userlevel 1
Badge

For the evaluation you can also use the WDK Get-Win32App to check if the application is installed

here is how I plan to do it when it comes time to deploy 

Evaluation: 

$ProductName = Get-Win32App | Where-Object {$_.Name -eq "Microsoft Office LTSC Professional Plus 2021 - en-us"}

If($ProductName){
# Product is installed
exit 0
}else {
# Product is not installed
exit 1 # to continue installation
}

 

Reply