Revisions for untitled paste

View the changes made to this paste.

unlisted ⁨2⁩ ⁨files⁩ 2022-06-05 05:54:02 UTC

sdn.new.ps1

@@ -0,0 +1,192 @@

+$ErrorActionPreference = "SilentlyContinue"
+#$ErrorActionPreference = "Continue"
+
+# Check Powershell version
+# This script requires Powershell 6+ due to Remove-Service cmdlet
+If ($PSVersionTable.PSVersion.Major -lt 6) {
+    Exit 1
+}
+
+# Delete WinDivert service if exists
+$wd = "WinDivert1.4"
+$service = Get-Service -Name $wd
+If ($service.Length -gt 0) {
+    If ((Get-Service -Name $wd).Status -eq 'Running') {
+        Stop-Service -InputObject $wd -Force
+    }
+    Remove-Service -Name $wd
+}
+
+# Cleanup TEMP directory without deleting TEMP directory
+If (-Not (Test-Path -Path $Env:Temp -PathType Container)) {
+    New-Item -Path $Env:LocalAppdata -Name "Temp" -ItemType Directory
+}
+Remove-Item -Path "$Env:Temp\*" -Recurse -Force
+
+# Cleanup Appdata
+$ad_dir = @(
+    ".minecraft\webcache2"
+    ".mono"
+    "Adguard Software Ltd"
+    "Code\Cache"
+    "Code\Code Cache"
+    "Code\GPUCache"
+    "Code\logs"
+    "discord\Cache"
+    "discord\Code Cache"
+    "discord\GPUCache"
+    "DMCache"
+    "mpv"
+    "NVIDIA"
+    "obs-studio\logs"
+    "Process Hacker\cache"
+    "ZeqMacaw"
+)
+ForEach ($item in $ad_dir) {
+    Remove-Item -Path "$Env:Appdata\$item" -Recurse -Force 
+}
+
+# Cleanup LocalAppdata
+$lad_dir = @(
+    ".ftba"
+    "Adobe"
+    "apktool"
+    "cache"
+    "clink"
+    "CrashDumps"
+    "CrashReportClient"
+    "CrashRpt"
+    "D3DSCache"
+    "DBG"
+    "Frija"
+    "Google\CrashReports"
+    "Google\Software Reporter Tool"
+    "JetBrains\IdeaIC2022.1\log"
+    "JetBrains\IdeaIC2022.1\vcs-log"
+    "Jonas_John"
+    "Live++"
+    "mcaselector"
+    "NBTExplorer"
+    "Nem's Tools"
+    "npm-cache"
+    "NuGet\Cache"
+    "NVIDIA\DXCache"
+    "NVIDIA\GLCache"
+    "Overwolf\BrowserCache"
+    "Package Cache"
+    "PeerDistRepub"
+    "pip"
+    "pypa"
+    "Skyrim Special Edition"
+    "Sony\ErrorReport"
+    "speech"
+    "SquirrelTemp"
+    "Steam"
+)
+ForEach ($item in $lad_dir) {
+    Remove-Item -Path "$Env:LocalAppdata\$item" -Recurse -Force 
+}
+
+# Cleanup UserProfile
+$up_dir = @(
+    "ansel"
+    "vmlogs"
+)
+ForEach ($item in $up_dir) {
+    Remove-Item -Path "$Env:UserProfile\$item" -Recurse -Force
+}
+
+# Delete MS input
+If (Test-Path "$Env:LocalAppdata\Microsoft\input\" -PathType Container) {
+    Remove-Item -Path "$Env:LocalAppdata\Microsoft\input\" -Recurse -Force
+    $f = New-Object System.IO.FileStream "$Env:LocalAppdata\Microsoft\input", Create, ReadWrite
+    $f.SetLength(0)
+    $f.Close()
+}
+
+# Delete auto-generated directory
+$uw_dir = @(
+    "E:\PICTURE\Camera Roll"
+    "E:\PICTURE\Saved Pictures"
+    "E:\VIDEO\Captures"
+)
+ForEach ($item in $uw_dir) {
+    Remove-Item -Path "$item" -Recurse -Force
+}
+
+# Delete logs
+$logs_loc = @(
+    "$Env:LocalAppdata"
+    "$Env:Appdata"
+)
+ForEach ($item in $logs_loc) {
+    Get-ChildItem -Path "$item\*" -Recurse -Force -Include *.log *.log.txt | Remove-Item -Force
+}
+
+# Cleanup NOX App Player
+$nox_file_up = @(
+    "d4ac4633ebd6440fa397b84f1bc94a3c.7z"
+    "inst.ini"
+    "nuuid.ini"
+    "useruid.ini"
+)
+ForEach ($item in $nox_file_up) {
+    Remove-Item -Path "$Env:UserProfile\$item" -Force
+}
+$nox_dir = @(
+    "$Env:LocalAppdata\MultiPlayerManager\app_images"
+    "$Env:UserProfile\Nox_share"
+)
+ForEach ($item in $nox_dir) {
+    Remove-Item -Path "$item" -Recurse -Force
+}
+Get-ChildItem -Path "$Env:UserProfile\.BigNox\*" -File -Include "NoxVMSVC.log*" | Remove-Item -Force
+Get-ChildItem -Path "$Env:LocalAppdata\Nox\*" -File -Include "Nox.log.*" | Remove-Item -Force
+
+# Prevent NOX App Player ads
+If (Test-Path -Path "$Env:LocalAppdata\Nox\loading" -PathType Container) {
+    Write-Host "Prevent NOX App Player ads" -ForegroundColor DarkGreen -BackgroundColor Gray
+    Remove-Item -Path "$Env:LocalAppdata\Nox\loading" -Recurse -Force
+    $f = New-Object System.IO.FileStream "$Env:LocalAppdata\Nox\loading", Create, ReadWrite
+    $f.SetLength(0)
+    $f.Close()
+    $acl = Get-Acl -Path "$Env:LocalAppdata\Nox\loading"
+    $ar = New-Object System.Security.AccessControl.FileSystemAccessRule("SYSTEM", "FullControl", "Deny")
+    $acl.Access | ForEach-Object{$acl.RemoveAccessRule($_)}
+    $acl.SetAccessRule($ar)
+    Set-Acl -Path "$Env:LocalAppdata\Nox\loading" -AclObject $acl
+}
+
+# Cleanup LD Player
+$ld_dir = @(
+    "$Env:Appdata\changzhi2"
+    "$Env:Appdata\lddownloader"
+    "$Env:Appdata\XuanZhi64\log"
+    "$Env:UserProfile\.Ld2VirtualBox"
+)
+ForEach ($item in $ld_dir) {
+    Remove-Item -Path "$item" -Recurse -Force
+}
+
+# Remove Empty Directories
+$red_list = @(
+    "$Env:Appdata\Adobe"
+    "$Env:Appdata\Code"
+    "$Env:Appdata\Google"
+    "$Env:Appdata\JetBrains"
+    "$Env:LocalAppdata\Nox"
+)
+$tailRecursion = {
+    param($Path)
+    ForEach ($childDir in Get-ChildItem -LiteralPath $Path -Directory) {
+        & $tailRecursion -Path $childDir.FullName
+    }
+    $currentChildren = Get-ChildItem -LiteralPath $Path -Force
+    $isEmpty = $currentChildren -eq $null
+    if ($isEmpty) {
+        Remove-Item -LiteralPath $Path -Force
+    }
+}
+ForEach ($item in $red_list) {
+    & $tailRecursion -Path $item
+}

sdn.old.bat

@@ -0,0 +1,110 @@

+REM Clear TEMP directory without deleting it
+cd /d %LocalAppdata%
+mkdir Temp 2> nul
+cd /d %temp%
+for /F "delims=" %%i in ('dir /b') do (rmdir "%%i" /s /q || del "%%i" /s /q) 2> nul
+
+REM Remove WinDivert service
+setlocal
+set "windivert=WinDivert1.4"
+sc query | findstr /C:"SERVICE_NAME: %windivert%"
+if ERRORLEVEL 1 (
+	sc stop %windivert%
+	sc delete %windivert%
+)
+endlocal
+
+REM Delete directory 1 - Cleanup LocalAppdata, Appdata, UserProfile
+rmdir /S /Q "%Appdata%\.minecraft\webcache2" 2> nul
+rmdir /S /Q "%Appdata%\.mono" 2> nul
+rmdir /S /Q "%Appdata%\Adguard Software Ltd" 2> nul
+rmdir /S /Q "%Appdata%\Code\Cache" 2> nul
+rmdir /S /Q "%Appdata%\Code\Code Cache" 2> nul
+rmdir /S /Q "%Appdata%\Code\GPUCache" 2> nul
+rmdir /S /Q "%Appdata%\Code\logs" 2> nul
+rmdir /S /Q "%Appdata%\discord\Cache" 2> nul
+rmdir /S /Q "%Appdata%\discord\Code Cache" 2> nul
+rmdir /S /Q "%Appdata%\discord\GPUCache" 2> nul
+rmdir /S /Q "%Appdata%\DMCache" 2> nul
+rmdir /S /Q "%Appdata%\mpv" 2> nul
+rmdir /S /Q "%Appdata%\NVIDIA" 2> nul
+rmdir /S /Q "%Appdata%\obs-studio\logs" 2> nul
+rmdir /S /Q "%Appdata%\Process Hacker\cache" 2> nul
+rmdir /S /Q "%Appdata%\ZeqMacaw" 2> nul
+
+rmdir /S /Q "%LocalAppdata%\.ftba" 2> nul
+rmdir /S /Q "%LocalAppdata%\Adobe" 2> nul
+rmdir /S /Q "%LocalAppdata%\apktool" 2> nul
+rmdir /S /Q "%LocalAppdata%\cache" 2> nul
+rmdir /S /Q "%LocalAppdata%\clink" 2> nul
+rmdir /S /Q "%LocalAppdata%\CrashDumps" 2> nul
+rmdir /S /Q "%LocalAppdata%\CrashReportClient" 2> nul
+rmdir /S /Q "%LocalAppdata%\CrashRpt" 2> nul
+rmdir /S /Q "%LocalAppdata%\D3DSCache" 2> nul
+rmdir /S /Q "%LocalAppdata%\DBG" 2> nul
+rmdir /S /Q "%LocalAppdata%\Frija" 2> nul
+rmdir /S /Q "%LocalAppdata%\Google\CrashReports" 2> nul
+rmdir /S /Q "%LocalAppdata%\Google\Software Reporter Tool" 2> nul
+rmdir /S /Q "%LocalAppdata%\JetBrains\IdeaIC2021.2\log" 2> nul
+rmdir /S /Q "%LocalAppdata%\JetBrains\IdeaIC2021.2\vcs-log" 2> nul
+rmdir /S /Q "%LocalAppdata%\Jonas_John" 2> nul
+rmdir /S /Q "%LocalAppdata%\Live++" 2> nul
+rmdir /S /Q "%LocalAppdata%\mcaselector" 2> nul
+rmdir /S /Q "%LocalAppdata%\NBTExplorer" 2> nul
+rmdir /S /Q "%LocalAppdata%\Nem's Tools" 2> nul
+rmdir /S /Q "%LocalAppdata%\npm-cache" 2> nul
+rmdir /S /Q "%LocalAppdata%\NuGet\Cache" 2> nul
+rmdir /S /Q "%LocalAppdata%\NVIDIA\DXCache" 2> nul
+rmdir /S /Q "%LocalAppdata%\NVIDIA\GLCache" 2> nul
+rmdir /S /Q "%LocalAppdata%\Overwolf\BrowserCache" 2> nul
+rmdir /S /Q "%LocalAppdata%\Package Cache" 2> nul
+rmdir /S /Q "%LocalAppdata%\PeerDistRepub" 2> nul
+rmdir /S /Q "%LocalAppdata%\pip" 2> nul
+rmdir /S /Q "%LocalAppdata%\pypa" 2> nul
+rmdir /S /Q "%LocalAppdata%\Skyrim Special Edition" 2> nul
+rmdir /S /Q "%LocalAppdata%\Sony\ErrorReport" 2> nul
+rmdir /S /Q "%LocalAppdata%\speech" 2> nul
+rmdir /S /Q "%LocalAppdata%\SquirrelTemp" 2> nul
+rmdir /S /Q "%LocalAppdata%\Steam" 2> nul
+
+rmdir /S /Q "%UserProfile%\ansel" 2> nul
+rmdir /S /Q "%UserProfile%\vmlogs" 2> nul
+
+REM Delete Directory 2 - Delete MS input
+if exist "%LocalAppdata%\Microsoft\input\" (
+	rmdir /S /Q "%LocalAppdata%\Microsoft\input" 2> nul
+	fsutil file createnew "%LocalAppdata%\Microsoft\input" 0 2>nul
+)
+
+REM Delete Directory 3
+rmdir /S /Q "E:\VIDEO\Captures" 2> nul
+rmdir /S /Q "E:\PICTURE\Camera Roll" 2> nul
+rmdir /S /Q "E:\PICTURE\Saved Pictures" 2>nul
+
+REM Delete log files
+cd /d %LocalAppdata%
+del /S *.log 2> nul
+del /S *.log.txt 2> nul
+cd /d %Appdata%
+del /S *.log 2> nul
+del /S *.log.txt 2> nul
+
+REM Cleanup NOX
+del /S "%UserProfile%\.BigNox\NoxVMSVC.log*" 2> nul
+del /S "%UserProfile%\d4ac4633ebd6440fa397b84f1bc94a3c.7z" 2> nul
+del /S "%UserProfile%\nuuid.ini" 2> nul
+del /S "%UserProfile%\useruid.ini" 2> nul
+rmdir /S /Q "%LocalAppdata%\MultiPlayerManager\app_images" 2> nul
+rmdir /S /Q "%UserProfile%\Nox_share" 2> nul
+
+REM Cleanup LD
+rmdir /S /Q "%Appdata%\changzhi2" 2> nul
+rmdir /S /Q "%Appdata%\lddownloader" 2> nul
+rmdir /S /Q "%Appdata%\XuanZhi64\log" 2> nul
+rmdir /S /Q "%UserProfile%\.Ld2VirtualBox" 2> nul
+
+REM Disable Ads in LDPlayer
+rem rmdir /S /Q "%Appdata%\XuanZhi64\cache" 2>nul
+rem echo Y|cacls "%AppData%\XuanZhi64\cache" /T /D SYSTEM
+
+exit
\ No newline at end of file