faelcolt

Pausar Backup FTP (2026)

Jul 15th, 2026 (edited)
18
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.24 KB | None | 0 0
  1. @echo off
  2. setlocal EnableExtensions
  3. title Parar Backup FTP Automatico
  4.  
  5. :: Solicita permissao de administrador
  6. net session >nul 2>&1
  7. if not "%errorlevel%"=="0" (
  8. echo Solicitando permissao de administrador...
  9. powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "Start-Process -FilePath '%~f0' -Verb RunAs"
  10. exit /b
  11. )
  12.  
  13. set "LOG=%USERPROFILE%\Desktop\Parar-Backup-FTP.log"
  14.  
  15. echo ============================================================ > "%LOG%"
  16. echo PARAR BACKUP FTP AUTOMATICO >> "%LOG%"
  17. echo Data: %date% %time% >> "%LOG%"
  18. echo ============================================================ >> "%LOG%"
  19.  
  20. echo.
  21. echo Procurando tarefas, servicos, processos e inicializacoes
  22. echo relacionados a "Backup FTP"...
  23. echo.
  24.  
  25. powershell.exe -NoProfile -ExecutionPolicy Bypass -Command ^
  26. "$ErrorActionPreference = 'SilentlyContinue';" ^
  27. "$pattern = 'backup[\s_-]*ftp';" ^
  28. "$log = $env:USERPROFILE + '\Desktop\Parar-Backup-FTP.log';" ^
  29. "function Log([string]$Text) { $Text | Tee-Object -FilePath $log -Append };" ^
  30. "Log '';" ^
  31. "Log '=== TAREFAS AGENDADAS ===';" ^
  32. "$tasks = Get-ScheduledTask | Where-Object {" ^
  33. " $actions = ($_.Actions | ForEach-Object { ($_.Execute + ' ' + $_.Arguments + ' ' + $_.WorkingDirectory) }) -join ' ';" ^
  34. " ($_.TaskName + ' ' + $_.TaskPath + ' ' + $actions) -match $pattern" ^
  35. "};" ^
  36. "if ($tasks) {" ^
  37. " foreach ($task in $tasks) {" ^
  38. " try { Stop-ScheduledTask -TaskName $task.TaskName -TaskPath $task.TaskPath -ErrorAction SilentlyContinue } catch {};" ^
  39. " try {" ^
  40. " Disable-ScheduledTask -TaskName $task.TaskName -TaskPath $task.TaskPath -ErrorAction Stop | Out-Null;" ^
  41. " Log ('DESATIVADA: ' + $task.TaskPath + $task.TaskName)" ^
  42. " } catch { Log ('ERRO AO DESATIVAR: ' + $task.TaskPath + $task.TaskName) }" ^
  43. " }" ^
  44. "} else { Log 'Nenhuma tarefa correspondente encontrada.' };" ^
  45. "Log '';" ^
  46. "Log '=== SERVICOS DO WINDOWS ===';" ^
  47. "$services = Get-CimInstance Win32_Service | Where-Object { ($_.Name + ' ' + $_.DisplayName + ' ' + $_.PathName) -match $pattern };" ^
  48. "if ($services) {" ^
  49. " foreach ($service in $services) {" ^
  50. " try { Stop-Service -Name $service.Name -Force -ErrorAction SilentlyContinue } catch {};" ^
  51. " try {" ^
  52. " Set-Service -Name $service.Name -StartupType Disabled -ErrorAction Stop;" ^
  53. " Log ('DESATIVADO: ' + $service.Name + ' - ' + $service.DisplayName)" ^
  54. " } catch { Log ('ERRO AO DESATIVAR: ' + $service.Name) }" ^
  55. " }" ^
  56. "} else { Log 'Nenhum servico correspondente encontrado.' };" ^
  57. "Log '';" ^
  58. "Log '=== PROCESSOS EM EXECUCAO ===';" ^
  59. "$processes = Get-CimInstance Win32_Process | Where-Object {" ^
  60. " $_.ProcessId -ne $PID -and (($_.Name + ' ' + $_.ExecutablePath + ' ' + $_.CommandLine) -match $pattern)" ^
  61. "};" ^
  62. "if ($processes) {" ^
  63. " foreach ($process in $processes) {" ^
  64. " try {" ^
  65. " Stop-Process -Id $process.ProcessId -Force -ErrorAction Stop;" ^
  66. " Log ('ENCERRADO: ' + $process.Name + ' PID=' + $process.ProcessId)" ^
  67. " } catch { Log ('ERRO AO ENCERRAR: ' + $process.Name + ' PID=' + $process.ProcessId) }" ^
  68. " }" ^
  69. "} else { Log 'Nenhum processo correspondente encontrado.' };" ^
  70. "Log '';" ^
  71. "Log '=== PASTAS DE INICIALIZACAO ===';" ^
  72. "$startupFolders = @(" ^
  73. " [Environment]::GetFolderPath('Startup')," ^
  74. " [Environment]::GetFolderPath('CommonStartup')" ^
  75. ") | Where-Object { $_ -and (Test-Path $_) };" ^
  76. "$startupFound = $false;" ^
  77. "$shell = New-Object -ComObject WScript.Shell;" ^
  78. "foreach ($folder in $startupFolders) {" ^
  79. " Get-ChildItem -LiteralPath $folder -File -Force | ForEach-Object {" ^
  80. " $file = $_;" ^
  81. " $text = $file.Name + ' ' + $file.FullName;" ^
  82. " if ($file.Extension -ieq '.lnk') {" ^
  83. " try {" ^
  84. " $shortcut = $shell.CreateShortcut($file.FullName);" ^
  85. " $text += ' ' + $shortcut.TargetPath + ' ' + $shortcut.Arguments + ' ' + $shortcut.WorkingDirectory" ^
  86. " } catch {}" ^
  87. " } elseif ($file.Extension -match '\.(bat|cmd|ps1|vbs|js|url|txt)$') {" ^
  88. " try { $text += ' ' + (Get-Content -LiteralPath $file.FullName -Raw -ErrorAction SilentlyContinue) } catch {}" ^
  89. " }" ^
  90. " if ($text -match $pattern) {" ^
  91. " $startupFound = $true;" ^
  92. " $newName = $file.FullName + '.disabled';" ^
  93. " if (Test-Path $newName) { $newName = $file.FullName + '.' + (Get-Date -Format 'yyyyMMddHHmmss') + '.disabled' };" ^
  94. " try {" ^
  95. " Rename-Item -LiteralPath $file.FullName -NewName ([IO.Path]::GetFileName($newName)) -ErrorAction Stop;" ^
  96. " Log ('DESATIVADO NA INICIALIZACAO: ' + $file.FullName)" ^
  97. " } catch { Log ('ERRO AO DESATIVAR INICIALIZACAO: ' + $file.FullName) }" ^
  98. " }" ^
  99. " }" ^
  100. "};" ^
  101. "if (-not $startupFound) { Log 'Nenhum arquivo correspondente encontrado nas pastas de inicializacao.' };" ^
  102. "Log '';" ^
  103. "Log '=== REGISTRO: RUN / RUNONCE ===';" ^
  104. "$backupDir = $env:USERPROFILE + '\Desktop\BackupFTP-Registro';" ^
  105. "New-Item -ItemType Directory -Path $backupDir -Force | Out-Null;" ^
  106. "$regLocations = @(" ^
  107. " @{ Ps='HKCU:\Software\Microsoft\Windows\CurrentVersion\Run'; Native='HKCU\Software\Microsoft\Windows\CurrentVersion\Run'; File='HKCU-Run.reg' }," ^
  108. " @{ Ps='HKCU:\Software\Microsoft\Windows\CurrentVersion\RunOnce'; Native='HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnce'; File='HKCU-RunOnce.reg' }," ^
  109. " @{ Ps='HKLM:\Software\Microsoft\Windows\CurrentVersion\Run'; Native='HKLM\Software\Microsoft\Windows\CurrentVersion\Run'; File='HKLM-Run.reg' }," ^
  110. " @{ Ps='HKLM:\Software\Microsoft\Windows\CurrentVersion\RunOnce'; Native='HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce'; File='HKLM-RunOnce.reg' }," ^
  111. " @{ Ps='HKLM:\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Run'; Native='HKLM\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Run'; File='HKLM-WOW6432-Run.reg' }" ^
  112. ");" ^
  113. "$regFound = $false;" ^
  114. "foreach ($location in $regLocations) {" ^
  115. " if (Test-Path $location.Ps) {" ^
  116. " $props = Get-ItemProperty -Path $location.Ps;" ^
  117. " $names = $props.PSObject.Properties | Where-Object { $_.Name -notmatch '^PS' };" ^
  118. " $matches = $names | Where-Object { ($_.Name + ' ' + [string]$_.Value) -match $pattern };" ^
  119. " if ($matches) {" ^
  120. " $regFound = $true;" ^
  121. " & reg.exe export $location.Native ($backupDir + '\' + $location.File) /y | Out-Null;" ^
  122. " foreach ($match in $matches) {" ^
  123. " try {" ^
  124. " Remove-ItemProperty -Path $location.Ps -Name $match.Name -ErrorAction Stop;" ^
  125. " Log ('REMOVIDO DA INICIALIZACAO DO REGISTRO: ' + $location.Native + ' -> ' + $match.Name + ' = ' + [string]$match.Value)" ^
  126. " } catch { Log ('ERRO AO REMOVER DO REGISTRO: ' + $location.Native + ' -> ' + $match.Name) }" ^
  127. " }" ^
  128. " }" ^
  129. " }" ^
  130. "};" ^
  131. "if (-not $regFound) { Log 'Nenhuma entrada correspondente encontrada no Registro.' };" ^
  132. "Log '';" ^
  133. "Log '=== RESULTADO ===';" ^
  134. "Log 'Verificacao concluida. Os itens encontrados foram interrompidos e desativados.';" ^
  135. "Log 'Nenhum arquivo da pasta de backup foi excluido.';" ^
  136. "Log ('Log salvo em: ' + $log);" ^
  137. "Write-Host '';" ^
  138. "Write-Host 'Concluido.' -ForegroundColor Green;" ^
  139. "Write-Host ('Relatorio salvo em: ' + $log);" ^
  140. "Write-Host 'Nenhum arquivo de backup foi apagado.';"
  141.  
  142. echo.
  143. echo A janela sera fechada automaticamente em 10 segundos.
  144. timeout /t 10 /nobreak >nul
  145. exit /b
  146.  
Advertisement
Add Comment
Please, Sign In to add comment