<#
Версия 1.03.
В связи с тем, что скрипт в Приложении SCCM не может проверить все профили на наличии в них файлов Vinteo устаревших версий,
принято решение запускать скрипт удаления на всех машинах по умолчанию.
Признаком успешного выполнения Удалятора является создание папки C:\TEMP И размещение в ней файла VinteoRemover.log.
Там же размещается файл VinteoUninstall.log, в котором прописываются результаты всех этапов удаления.
Данный скрипт выполняется в Удаляторе, который исполняется перед установкой Vinteo 4.15.2.
Удалятор для Винтео с расширенным логированием.
#>
# Пути к логам
$mainLog = "C:\TEMP\VinteoUninstall.log"
$flagFile = "C:\TEMP\VinteoRemover.log"
# Функция логирования
function Write-Log {
param ([string]$Message)
$timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
"$timestamp `t $Message" | Out-File -FilePath $mainLog -Append -Encoding UTF8
Write-Host $Message
}
# Создать каталог для логов при необходимости
if (-not (Test-Path "C:\TEMP")) {
New-Item -Path "C:\TEMP" -ItemType Directory -Force | Out-Null
Write-Log "Создана папка C:\TEMP"
}
Write-Log "=== Этап 1: START Удаление Vinteo Desktop ==="
# --- Завершение процессов ---
Get-Process | Where-Object { $_.Name -like "*Vinteo*" } | ForEach-Object {
try {
Write-Log "Завершаю процесс: $($_.Name) (ID: $($_.Id))"
Stop-Process -Id $_.Id -Force
Write-Log "Процесс $($_.Name) завершён GOOD"
} catch {
Write-Log "Ошибка при завершении процесса: $_"
}
}
# --- Удаление через UninstallString ---
Write-Log "=== Этап 2: Удаление через UninstallString ==="
$regPaths = @(
"HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*",
"HKLM:\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*",
"HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*"
)
foreach ($regPath in $regPaths) {
Get-ItemProperty $regPath -ErrorAction SilentlyContinue | Where-Object {
$_.DisplayName -like "*Vinteo*"
} | ForEach-Object {
Write-Log "Найдена установленная версия: $($_.DisplayName)"
$uninstallCmd = $_.UninstallString
$parentPath = $_.PSPath
try {
if ($uninstallCmd -match "msiexec\.exe.*\{([0-9A-Fa-f\-]+)\}") {
$guid = $Matches[1]
Write-Log "Удаление MSI по GUID: $guid"
Start-Process "msiexec.exe" -ArgumentList "/x {$guid} /qn" -Wait -NoNewWindow
}
elseif ($uninstallCmd -match "\.exe") {
$exePath = $uninstallCmd.Trim('"')
if (Test-Path $exePath) {
$args = "/S"
if ($exePath -match "unins.*\.exe") { $args = "/VERYSILENT /SUPPRESSMSGBOXES" }
Write-Log "Тихое удаление EXE: $exePath $args"
Start-Process -FilePath $exePath -ArgumentList $args -Wait -NoNewWindow
} else {
Write-Log "Файл не найден: $exePath"
}
} else {
Write-Log "Неизвестный формат uninstall-команды: $uninstallCmd"
}
Write-Log "Удаляю запись из Uninstall: $parentPath"
Remove-Item -Path $parentPath -Recurse -Force
} catch {
Write-Log "Ошибка при удалении: $_"
}
}
}
Write-Log "Этап 2 FINAL"
# --- Удаление папок ---
Write-Log "=== Этап 3: Удаление папок Vinteo ==="
$pathsPF = @("$env:ProgramFiles\Vinteo*", "$env:ProgramFiles(x86)\Vinteo*")
foreach ($path in $pathsPF) {
Get-ChildItem -Path $path -Directory -ErrorAction SilentlyContinue | ForEach-Object {
try {
Write-Log "Удаляю папку: $($_.FullName)"
Remove-Item -Recurse -Force -Path $_.FullName
} catch {
Write-Log "Ошибка при удалении папки: $($_.FullName) - $_"
}
}
}
Write-Log "Этап 3 FINAL"
# --- Чистка профилей ---
Write-Log "=== Этап 4: Чистка профилей пользователей ==="
$users = Get-ChildItem C:\Users -Directory -Exclude "Public","Default","Default User","All Users"
foreach ($user in $users) {
$userAppPath = "C:\Users\$($user.Name)\AppData\Local\Programs"
if (Test-Path $userAppPath) {
Get-ChildItem -Path "$userAppPath\Vinteo*" -Directory -ErrorAction SilentlyContinue | ForEach-Object {
try {
Write-Log "Удаляю из профиля $($user.Name): $($_.FullName)"
Remove-Item -Recurse -Force -Path $_.FullName
} catch {
Write-Log "Ошибка при удалении из профиля $($user.Name): $_"
}
}
}
}
Write-Log "Этап 4 FINAL"
#--- Удаление ярлыков ---
Write-Log "=== Этап 5: Чистка ярлыков ==="
foreach ($user in $users) {
$desktopPath = "C:\Users\$($user.Name)\Desktop"
if (Test-Path $desktopPath) {
Get-ChildItem -Path $desktopPath -Filter "*.lnk" -ErrorAction SilentlyContinue | Where-Object {
$_.Name -like "*Vinteo*"
} | ForEach-Object {
try {
Write-Log "Удаляю ярлык: $($_.FullName)"
Remove-Item -Path $_.FullName -Force
} catch {
Write-Log "Ошибка при удалении ярлыка $($_.FullName): $_"
}
}
}
}
$publicDesktop = "C:\Users\Public\Desktop"
if (Test-Path $publicDesktop) {
Get-ChildItem -Path $publicDesktop -Filter "*.lnk" -ErrorAction SilentlyContinue | Where-Object {
$_.Name -like "*Vinteo*"
} | ForEach-Object {
try {
Write-Log "Удаляю ярлык: $($_.FullName)"
Remove-Item -Path $_.FullName -Force
} catch {
Write-Log "Ошибка при удалении ярлыка $($_.FullName): $_"
}
}
}
Write-Log "Этап 5 FINAL"
# --- Завершение ---
Write-Log "=== УДАЛЕНИЕ ЗАВЕРШЕНО SUCCESS ==="
# Создаём флаговый файл
New-Item -Path $flagFile -ItemType File -Force | Out-Null
Write-Log "Файл-признак создан: $flagFile"