added a few fixes
This commit is contained in:
@@ -19,19 +19,23 @@ End-Process -Name 'Teams' -Match -Force
|
||||
# URL to the OffscrubC2R.vbs script
|
||||
$UninstallScriptURL = 'https://github.com/OfficeDev/Office-IT-Pro-Deployment-Scripts/raw/master/Office-ProPlus-Deployment/Deploy-OfficeClickToRun/OffScrubc2r.vbs'
|
||||
|
||||
# The path to the local script once downloaded
|
||||
$UninstallScript = Download-File -URL $UninstallScriptURL
|
||||
# Use an owned, unique file so partial downloads can also be removed in finally.
|
||||
$UninstallScript = Join-Path (Get-TempPath) ('OfficeUninstall-' + [guid]::NewGuid().ToString('N') + '.vbs')
|
||||
|
||||
# Args to pass to the OffscrubC2R.vbs script
|
||||
$ScriptArgs = "/ALL /QUIET /NOCANCEL"
|
||||
|
||||
# Run the script
|
||||
Write-Output "Uninstalling all Click2Run versions of Office"
|
||||
Try { Start-Process "cscript.exe" -ArgumentList "//nologo ""${UninstallScript}"" ${ScriptArgs}" -Wait }
|
||||
Catch { Write-Error $_.Exception.Message }
|
||||
|
||||
# Delete the downloaded script
|
||||
If ( Test-Path $UninstallScript ) {
|
||||
Write-Output "Deleting downloaded script: ""${UninstallScript}"""
|
||||
Remove-Item -Path $UninstallScript -Force -ErrorAction SilentlyContinue
|
||||
}
|
||||
try {
|
||||
$null = Download-File -URL $UninstallScriptURL -File $UninstallScript
|
||||
Write-Output 'Uninstalling all Click2Run versions of Office'
|
||||
Start-Process 'cscript.exe' -ArgumentList "//nologo `"$UninstallScript`" $ScriptArgs" -Wait -WindowStyle Hidden -ErrorAction Stop
|
||||
} catch {
|
||||
Write-Error $_.Exception.Message -ErrorAction Continue
|
||||
throw
|
||||
} finally {
|
||||
if (Test-Path -LiteralPath $UninstallScript -PathType Leaf) {
|
||||
Write-Output "Deleting downloaded script: $UninstallScript"
|
||||
try { Remove-Item -LiteralPath $UninstallScript -Force -ErrorAction Stop }
|
||||
catch { Write-Error "Could not delete $UninstallScript : $($_.Exception.Message)" -ErrorAction Continue }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user