@לומדעס
@echo off
:: Check if running with admin privileges
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
if '%errorlevel%' NEQ '0' (
echo Requesting administrative privileges...
goto UACPrompt
) else (
goto GetAccount
)
:UACPrompt
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
set params = %*:"=""
echo UAC.ShellExecute "cmd.exe", "/c %~s0 %params%", "", "runas", 1 >> "%temp%\getadmin.vbs"
"%temp%\getadmin.vbs"
del "%temp%\getadmin.vbs"
exit /B
:GetAccount
echo Enter the Microsoft Account email address to remove:
set /p account=
if not "%account%" == "" (
call :RemoveAccount "%account%"
) else (
echo No account entered. Exiting...
pause
exit /B
)
goto End
:RemoveAccount
:: Check if account exists in registry
reg query "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\AccountManager\Accounts\%~1" >nul 2>&1
if '%errorlevel%' EQU '0' (
:: Remove account from registry
reg delete "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\AccountManager\Accounts\%~1" /f
:: Check if account data folder exists
if exist "%localappdata%\Packages\Microsoft.AAD.BrokerPlugin_%~1_cw5n1h2txyewy" (
:: Remove account data folder
rd /s /q "%localappdata%\Packages\Microsoft.AAD.BrokerPlugin_%~1_cw5n1h2txyewy"
echo Microsoft Account %~1 has been removed successfully.
) else (
echo Microsoft Account %~1 has been removed from the registry, but no data folder was found.
)
) else (
echo Microsoft Account %~1 was not found on this system.
)
goto End
:End
pause
exit /B