Cogger

Office_Install.ps1

Sep 20th, 2021 (edited)
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. mkdir C:\OfficeSetup -EA SilentlyContinue
  2. Set-Location -Path 'C:\OfficeSetup'
  3. $CurrentDir = $(get-location).Path;
  4. Set-Location $CurrentDir
  5. $Key = Read-Host -Prompt 'Please paste the key here'
  6. $Note = "PIDKEY="
  7. $PIDKEY = [string]$Note + '"' + $Key + '"'
  8. Set-Content -Path "$CurrentDir\config1.xml" -Value {
  9. <Configuration>
  10.   <Info Description="Office Professional Plus 2019 (32-bit)" />
  11.   <Add OfficeClientEdition="32" Channel="PerpetualVL2019" SourcePath="C:\OfficeSetup">
  12.     <Product ID="ProPlus2019Volume" PIDKEY>
  13.       <Language ID="en-us" />
  14.     </Product>
  15.   </Add>
  16.   <RemoveMSI />
  17.   <Display Level="Full" AcceptEULA="TRUE" />
  18.   <Property Name="AUTOACTIVATE" Value="1" />
  19. </Configuration>
  20. }
  21.  
  22. $findString = 'PIDKEY'
  23. (Get-Content "$CurrentDir\config1.xml") | foreach {$_.replace($findString,$PIDKEY)} | Set-Content -Path "C:\OfficeSetup\config.xml"
  24. Remove-Item -Path "$CurrentDir\config1.xml"
  25.  
  26. Unblock-File -Path $CurrentDir\officedeploymenttool_12827-20268.exe
  27. Start officedeploymenttool_12827-20268.exe /extract:C:\OfficeSetup
  28.  
  29. sleep 5
  30. $wshell = New-Object -ComObject wscript.shell;
  31. $wshell.AppActivate('The Microsoft Office 2016 Click-to-Run Administrator Tool')
  32. Sleep 3
  33. $wshell.SendKeys('{TAB}')
  34. $wshell.SendKeys('{TAB}')
  35. $wshell.SendKeys(' '); Sleep 1
  36. $wshell.SendKeys('{TAB}')
  37. $wshell.SendKeys('~'); Sleep 1
  38.  
  39. $wshell = New-Object -ComObject wscript.shell;
  40. $wshell.AppActivate('The Microsoft Office 2016 Click-to-Run Administrator Tool')
  41. $wshell.SendKeys('~'); Sleep 1
  42.  
  43. Set-Location C:\OfficeSetup
  44.  
  45. cmd /c Setup.exe /download config.xml
  46. cmd /c Setup.exe /configure config.xml
  47.  
  48.  
  49. Start-Sleep -Seconds 30
  50.  
  51. Get-ChildItem * -Recurse | Remove-Item ; Sleep 2
  52. Set-Location $CurrentDir
  53.  
  54. &cmd.exe /c rd /s /q C:\OfficeSetup
  55.  
  56. Remove-Item -Path "$CurrentDir\OfficeSetup.ps1"
  57.  
Add Comment
Please, Sign In to add comment