0% found this document useful (0 votes)
8 views4 pages

Microsoft Office 365 Offline Installer

This document is a PowerShell script that creates a GUI for installing Microsoft Office 365 offline. It checks for administrative privileges, verifies the presence of 'setup.exe', and allows users to select which Office applications to install. The script generates an XML configuration file based on user selections and initiates the installation process.

Uploaded by

vikasbhartiya
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views4 pages

Microsoft Office 365 Offline Installer

This document is a PowerShell script that creates a GUI for installing Microsoft Office 365 offline. It checks for administrative privileges, verifies the presence of 'setup.exe', and allows users to select which Office applications to install. The script generates an XML configuration file based on user selections and initiates the installation process.

Uploaded by

vikasbhartiya
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

# =========================

# FORCE ADMIN
# =========================
$IsAdmin = ([[Link]] `
[[Link]]::GetCurrent() `
).IsInRole([[Link]]::Administrator)

if (-not $IsAdmin) {
Start-Process -FilePath
([[Link]]::GetCurrentProcess().[Link]) -Verb RunAs
exit
}

Add-Type -AssemblyName [Link]


Add-Type -AssemblyName [Link]

# =========================
# EXE LOCATION (DVD SAFE)
# =========================
$BasePath = [[Link]]::GetDirectoryName(
[[Link]]::GetCurrentProcess().[Link]
)

$SetupExe = Join-Path $BasePath "[Link]"

if (-not (Test-Path $SetupExe)) {


[[Link]]::Show(
"[Link] not found in:`n$BasePath",
"Critical Error",
[[Link]]::OK,
[[Link]]::Error
)
exit
}

# =========================
# FORM
# =========================
$form = New-Object [Link]
$[Link] = "Microsoft Office 365 Offline Installer"
$[Link] = New-Object [Link](520,520)
$[Link] = "CenterScreen"
$[Link] = "FixedDialog"
$[Link] = $false

$title = New-Object [Link]


$[Link] = "Select Office Applications"
$[Link] = New-Object [Link]("Segoe UI",14,
[[Link]]::Bold)
$[Link] = New-Object [Link](20,15)
$[Link] = $true

$panel = New-Object [Link]


$[Link] = New-Object [Link](20,60)
$[Link] = New-Object [Link](460,260)
$[Link] = $true
$[Link] = 'FixedSingle'
$chkAll = New-Object [Link]
$[Link] = "Select All"
$[Link] = New-Object [Link]("Segoe UI",10)
$[Link] = New-Object [Link](10,10)

$apps = @(
"Word","Excel","PowerPoint","Outlook",
"Access","Publisher","OneNote",
"Groove","Lync","Teams"
)

$checkboxes = @()
$y = 40
$left = 10
$right = 230

for ($i=0; $i -lt $[Link]; $i++) {


$chk = New-Object [Link]
$[Link] = $apps[$i]
$[Link] = New-Object [Link]("Segoe UI",10)
$[Link] = $true

if ($i % 2 -eq 0) {
$[Link] = New-Object [Link]($left,$y)
} else {
$[Link] = New-Object [Link]($right,$y)
$y += 30
}
$checkboxes += $chk
$[Link]($chk)
}

$[Link]($chkAll)

$chkAll.Add_CheckedChanged({
foreach ($c in $checkboxes) { $[Link] = $[Link] }
})

foreach ($c in $checkboxes) {


$c.Add_CheckedChanged({
if ($checkboxes | Where-Object { -not $_.Checked }) {
$[Link] = $false
} else {
$[Link] = $true
}
})
}

$btnInstall = New-Object [Link]


$[Link] = "Install"
$[Link] = New-Object [Link]("Segoe UI",12,
[[Link]]::Bold)
$[Link] = New-Object [Link](130,40)
$[Link] = New-Object [Link](130,350)

$btnCancel = New-Object [Link]


$[Link] = "Cancel"
$[Link] = $[Link]
$[Link] = $[Link]
$[Link] = New-Object [Link](270,350)

$status = New-Object [Link]


$[Link] = New-Object [Link](20,420)
$[Link] = $true
$[Link] = 'DarkGreen'

# =========================
# INSTALL CLICK
# =========================
$btnInstall.Add_Click({

if (-not ($checkboxes | Where-Object { $_.Checked })) {


[[Link]]::Show("Select at least one
app.","Warning")
return
}

$exclude = $checkboxes | Where-Object { -not $_.Checked } | ForEach-Object


{ $_.Text }

$xmlPath = Join-Path $env:TEMP "Office_Offline_Config.xml"

# =========================
# OPTIMIZED XML (FAST)
# =========================
$xml = @"
<Configuration>
<Add OfficeClientEdition="64"
SourcePath="$BasePath"
AllowCdnFallback="FALSE">

<Product ID="O365ProPlusRetail">
<Language ID="en-us" />
"@

foreach ($app in $exclude) {


$xml += " <ExcludeApp ID=`"$app`" />`n"
}

$xml += @"
</Product>
</Add>

<Property Name="AUTOACTIVATE" Value="1"/>


<Property Name="FORCEAPPSHUTDOWN" Value="TRUE"/>
<Property Name="SharedComputerLicensing" Value="0"/>

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


<Logging Level="Standard" Path="%temp%"/>
</Configuration>
"@

$xml | Out-File -Encoding UTF8 $xmlPath

$[Link] = "Installing Office (offline, optimized)..."

Start-Process -FilePath $SetupExe `


-ArgumentList "/configure `"$xmlPath`"" `
-Wait
})

$btnCancel.Add_Click({ $[Link]() })

$[Link](@(
$title,$panel,$btnInstall,$btnCancel,$status
))

$[Link]()

You might also like