- הוסף לסימניות
- #21
בוא אני יעזור לך
תפתחPowerShell כמנהל (קליק ימני על ההתחל)
תדביק לשמה את כל מה שבספוילר
יווצר לך קובץ על שולחן העבודה
תעלה אותו לפה
עריכה: מכיון ואני רואה שפרוג הופך חלק מהקוד לסמיילים תעתיק את הקוד קודם לכתבן תשמור אותו ואז תעתיק אותו לפאוורשל
תפתחPowerShell כמנהל (קליק ימני על ההתחל)
תדביק לשמה את כל מה שבספוילר
יווצר לך קובץ על שולחן העבודה
תעלה אותו לפה
# Office Install Block Report (run as Administrator)
# Creates a report of common Office / Click-to-Run leftovers that can block re-installation.
$ErrorActionPreference = "SilentlyContinue"
function Write-Section($title) {
$sep = ("=" * 70)
Add-Content -Path $Report -Value "`n$sep`n$title`n$sep"
}
# Report path
$Report = Join-Path $env:USERPROFILE "Desktop\OfficeInstallBlockReport.txt"
"Office Install Block Report - $(Get-Date)" | Out-File -FilePath $Report -Encoding UTF8
Write-Section "SYSTEM INFO"
Add-Content $Report ("Computer: " + $env:COMPUTERNAME)
Add-Content $Report ("User: " + $env:USERNAME)
Add-Content $Report ("OS: " + (Get-CimInstance Win32_OperatingSystem).Caption)
Add-Content $Report ("Build: " + (Get-CimInstance Win32_OperatingSystem).BuildNumber)
Add-Content $Report ("64-bit OS: " + [Environment]::Is64BitOperatingSystem)
Write-Section "RUNNING OFFICE-RELATED PROCESSES"
$proc = Get-Process | Where-Object {
$_.Name -match "office|clicktorun|c2r|winword|excel|powerpnt|outlook|onenote|msaccess|groove|teams"
} | Sort-Object Name
if ($proc) {
$proc | Select-Object Name, Id, Path | Format-Table -AutoSize | Out-String | Add-Content $Report
} else {
Add-Content $Report "No related processes found."
}
Write-Section "SERVICES (OFFICE/CLICK-TO-RUN)"
$svc = Get-Service | Where-Object {
$_.Name -match "ClickToRun|Office|C2R|osppsvc" -or $_.DisplayName -match "Office|Click-to-Run"
} | Sort-Object Name
if ($svc) {
$svc | Select-Object Name, DisplayName, Status, StartType | Format-Table -AutoSize | Out-String | Add-Content $Report
} else {
Add-Content $Report "No matching services found."
}
Write-Section "SERVICE DETAILS (BINPATH) - useful to identify problematic EXE"
$svcNames = @("ClickToRunSvc","OfficeSvc","osppsvc") + ($svc | Select-Object -ExpandProperty Name -ErrorAction SilentlyContinue)
$svcNames = $svcNames | Where-Object { $_ } | Select-Object -Unique
foreach ($n in $svcNames) {
$q = sc.exe qc $n 2>$null
if ($LASTEXITCODE -eq 0 -and $q) {
Add-Content $Report "`n--- sc qc $n ---"
Add-Content $Report ($q | Out-String)
}
}
Write-Section "SCHEDULED TASKS (Office/ClickToRun)"
$tasks = Get-ScheduledTask | Where-Object {
$_.TaskName -match "Office|ClickToRun|C2R|MicrosoftOffice|Subscription|Update" -or
$_.TaskPath -match "\\Microsoft\\Office\\|\\Microsoft\\OfficeClickToRun\\|\\Microsoft\\Windows\\Office\\"
}
if ($tasks) {
$tasks | Select-Object TaskName, TaskPath, State | Sort-Object TaskPath, TaskName |
Format-Table -AutoSize | Out-String | Add-Content $Report
} else {
Add-Content $Report "No matching scheduled tasks found."
}
Write-Section "COMMON LEFTOVER FOLDERS (existence + locked check)"
$paths = @(
"$env
rogramFiles\Microsoft Office",
"${env
rogramFiles(x86)}\Microsoft Office",
"$env
rogramFiles\Common Files\Microsoft Shared\ClickToRun",
"$env
rogramFiles\Common Files\Microsoft Shared\Office16",
"$env
rogramData\Microsoft\Office",
"$env
rogramData\Microsoft\ClickToRun",
"$env:LocalAppData\Microsoft\Office",
"$env:AppData\Microsoft\Office"
) | Where-Object { $_ -and ($_ -ne "\Microsoft Office") } | Select-Object -Unique
foreach ($p in $paths) {
$exists = Test-Path $p
Add-Content $Report ("{0} : {1}" -f $p, $(if($exists){"EXISTS"}else{"not found"}))
if ($exists) {
# Try to open a file handle to detect lock issues (best-effort)
try {
$tmp = Get-ChildItem -Path $p -Recurse -File -ErrorAction SilentlyContinue | Select-Object -First 1
if ($tmp) {
$fs = [System.IO.File]::Open($tmp.FullName,'Open','Read','ReadWrite')
$fs.Close()
Add-Content $Report (" Lock check: OK (sample file: " + $tmp.FullName + ")")
} else {
Add-Content $Report " Lock check: skipped (no files found in folder)"
}
} catch {
Add-Content $Report (" Lock check: POSSIBLY LOCKED (sample file access failed). Error: " + $_.Exception.Message)
}
}
}
Write-Section "INSTALLED OFFICE ENTRIES (Registry uninstall keys)"
$uninstallKeys = @(
"HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*",
"HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*"
)
$apps = foreach ($k in $uninstallKeys) {
Get-ItemProperty $k | Where-Object {
$_.DisplayName -match "Microsoft 365|Microsoft Office|Office(16|15|14)|Click-to-Run|Teams|Visio|Project"
} | Select-Object DisplayName, DisplayVersion, Publisher, InstallLocation, UninstallString
}
if ($apps) {
$apps | Sort-Object DisplayName | Format-Table -AutoSize | Out-String | Add-Content $Report
} else {
Add-Content $Report "No Office-related uninstall entries found."
}
Write-Section "RECENT INSTALLER EVENTS (may show the exact blocking component)"
# MSI Installer events
$msi = Get-WinEvent -FilterHashtable @{LogName='Application'; ProviderName='MsiInstaller'} -MaxEvents 80
if ($msi) {
$msi | Select-Object TimeCreated, Id, LevelDisplayName, Message |
Format-List | Out-String | Add-Content $Report
} else {
Add-Content $Report "No recent MsiInstaller events found."
}
# Click-to-Run operational log (if exists)
Write-Section "CLICK-TO-RUN EVENT LOG (if available)"
try {
$c2r = Get-WinEvent -LogName "Microsoft-OfficeClickToRun/Operational" -MaxEvents 120
if ($c2r) {
$c2r | Select-Object TimeCreated, Id, LevelDisplayName, Message |
Format-List | Out-String | Add-Content $Report
} else {
Add-Content $Report "No events found in OfficeClickToRun/Operational."
}
} catch {
Add-Content $Report "OfficeClickToRun/Operational log not available on this system."
}
Write-Section "QUICK ACTIONS (DO NOT auto-execute; suggestions only)"
Add-Content $Report @"
If you see ClickToRunSvc running:
Stop-Service ClickToRunSvc -Force
Set-Service ClickToRunSvc -StartupType Disabled
If a specific EXE appears in sc qc output (BINARY_PATH_NAME), that's the service binary.
If folders exist AND lock check says POSSIBLY LOCKED:
Identify locking process by matching process list paths.
Common offenders: OfficeClickToRun.exe, integrated Office update tasks.
After cleanup, re-enable services if needed:
Set-Service ClickToRunSvc -StartupType Manual
"@
Write-Section "END OF REPORT"
Add-Content $Report "Saved to: $Report"
Write-Host "Done. Report saved to:`n$Report"
# Creates a report of common Office / Click-to-Run leftovers that can block re-installation.
$ErrorActionPreference = "SilentlyContinue"
function Write-Section($title) {
$sep = ("=" * 70)
Add-Content -Path $Report -Value "`n$sep`n$title`n$sep"
}
# Report path
$Report = Join-Path $env:USERPROFILE "Desktop\OfficeInstallBlockReport.txt"
"Office Install Block Report - $(Get-Date)" | Out-File -FilePath $Report -Encoding UTF8
Write-Section "SYSTEM INFO"
Add-Content $Report ("Computer: " + $env:COMPUTERNAME)
Add-Content $Report ("User: " + $env:USERNAME)
Add-Content $Report ("OS: " + (Get-CimInstance Win32_OperatingSystem).Caption)
Add-Content $Report ("Build: " + (Get-CimInstance Win32_OperatingSystem).BuildNumber)
Add-Content $Report ("64-bit OS: " + [Environment]::Is64BitOperatingSystem)
Write-Section "RUNNING OFFICE-RELATED PROCESSES"
$proc = Get-Process | Where-Object {
$_.Name -match "office|clicktorun|c2r|winword|excel|powerpnt|outlook|onenote|msaccess|groove|teams"
} | Sort-Object Name
if ($proc) {
$proc | Select-Object Name, Id, Path | Format-Table -AutoSize | Out-String | Add-Content $Report
} else {
Add-Content $Report "No related processes found."
}
Write-Section "SERVICES (OFFICE/CLICK-TO-RUN)"
$svc = Get-Service | Where-Object {
$_.Name -match "ClickToRun|Office|C2R|osppsvc" -or $_.DisplayName -match "Office|Click-to-Run"
} | Sort-Object Name
if ($svc) {
$svc | Select-Object Name, DisplayName, Status, StartType | Format-Table -AutoSize | Out-String | Add-Content $Report
} else {
Add-Content $Report "No matching services found."
}
Write-Section "SERVICE DETAILS (BINPATH) - useful to identify problematic EXE"
$svcNames = @("ClickToRunSvc","OfficeSvc","osppsvc") + ($svc | Select-Object -ExpandProperty Name -ErrorAction SilentlyContinue)
$svcNames = $svcNames | Where-Object { $_ } | Select-Object -Unique
foreach ($n in $svcNames) {
$q = sc.exe qc $n 2>$null
if ($LASTEXITCODE -eq 0 -and $q) {
Add-Content $Report "`n--- sc qc $n ---"
Add-Content $Report ($q | Out-String)
}
}
Write-Section "SCHEDULED TASKS (Office/ClickToRun)"
$tasks = Get-ScheduledTask | Where-Object {
$_.TaskName -match "Office|ClickToRun|C2R|MicrosoftOffice|Subscription|Update" -or
$_.TaskPath -match "\\Microsoft\\Office\\|\\Microsoft\\OfficeClickToRun\\|\\Microsoft\\Windows\\Office\\"
}
if ($tasks) {
$tasks | Select-Object TaskName, TaskPath, State | Sort-Object TaskPath, TaskName |
Format-Table -AutoSize | Out-String | Add-Content $Report
} else {
Add-Content $Report "No matching scheduled tasks found."
}
Write-Section "COMMON LEFTOVER FOLDERS (existence + locked check)"
$paths = @(
"$env
"${env
"$env
"$env
"$env
"$env
"$env:LocalAppData\Microsoft\Office",
"$env:AppData\Microsoft\Office"
) | Where-Object { $_ -and ($_ -ne "\Microsoft Office") } | Select-Object -Unique
foreach ($p in $paths) {
$exists = Test-Path $p
Add-Content $Report ("{0} : {1}" -f $p, $(if($exists){"EXISTS"}else{"not found"}))
if ($exists) {
# Try to open a file handle to detect lock issues (best-effort)
try {
$tmp = Get-ChildItem -Path $p -Recurse -File -ErrorAction SilentlyContinue | Select-Object -First 1
if ($tmp) {
$fs = [System.IO.File]::Open($tmp.FullName,'Open','Read','ReadWrite')
$fs.Close()
Add-Content $Report (" Lock check: OK (sample file: " + $tmp.FullName + ")")
} else {
Add-Content $Report " Lock check: skipped (no files found in folder)"
}
} catch {
Add-Content $Report (" Lock check: POSSIBLY LOCKED (sample file access failed). Error: " + $_.Exception.Message)
}
}
}
Write-Section "INSTALLED OFFICE ENTRIES (Registry uninstall keys)"
$uninstallKeys = @(
"HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*",
"HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*"
)
$apps = foreach ($k in $uninstallKeys) {
Get-ItemProperty $k | Where-Object {
$_.DisplayName -match "Microsoft 365|Microsoft Office|Office(16|15|14)|Click-to-Run|Teams|Visio|Project"
} | Select-Object DisplayName, DisplayVersion, Publisher, InstallLocation, UninstallString
}
if ($apps) {
$apps | Sort-Object DisplayName | Format-Table -AutoSize | Out-String | Add-Content $Report
} else {
Add-Content $Report "No Office-related uninstall entries found."
}
Write-Section "RECENT INSTALLER EVENTS (may show the exact blocking component)"
# MSI Installer events
$msi = Get-WinEvent -FilterHashtable @{LogName='Application'; ProviderName='MsiInstaller'} -MaxEvents 80
if ($msi) {
$msi | Select-Object TimeCreated, Id, LevelDisplayName, Message |
Format-List | Out-String | Add-Content $Report
} else {
Add-Content $Report "No recent MsiInstaller events found."
}
# Click-to-Run operational log (if exists)
Write-Section "CLICK-TO-RUN EVENT LOG (if available)"
try {
$c2r = Get-WinEvent -LogName "Microsoft-OfficeClickToRun/Operational" -MaxEvents 120
if ($c2r) {
$c2r | Select-Object TimeCreated, Id, LevelDisplayName, Message |
Format-List | Out-String | Add-Content $Report
} else {
Add-Content $Report "No events found in OfficeClickToRun/Operational."
}
} catch {
Add-Content $Report "OfficeClickToRun/Operational log not available on this system."
}
Write-Section "QUICK ACTIONS (DO NOT auto-execute; suggestions only)"
Add-Content $Report @"
If you see ClickToRunSvc running:
Stop-Service ClickToRunSvc -Force
Set-Service ClickToRunSvc -StartupType Disabled
If a specific EXE appears in sc qc output (BINARY_PATH_NAME), that's the service binary.
If folders exist AND lock check says POSSIBLY LOCKED:
Identify locking process by matching process list paths.
Common offenders: OfficeClickToRun.exe, integrated Office update tasks.
After cleanup, re-enable services if needed:
Set-Service ClickToRunSvc -StartupType Manual
"@
Write-Section "END OF REPORT"
Add-Content $Report "Saved to: $Report"
Write-Host "Done. Report saved to:`n$Report"
עריכה: מכיון ואני רואה שפרוג הופך חלק מהקוד לסמיילים תעתיק את הקוד קודם לכתבן תשמור אותו ואז תעתיק אותו לפאוורשל
הנושאים החמים



Reactions: sol key ו-קוראים לי #C2 //