BaSs_HaXoR

RDP autologin LAN .bat

Nov 18th, 2025 (edited)
878
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 1.10 KB | None | 0 0
  1. :: -- BATCH SCRIPT TO RDP CONNECT WITH USER+PASSWORD DETAILS FOR EASY RDP -- ::
  2. :: -- Install https://nmap.org/ -- ::
  3. :: -- Open cmd, and type: whoami
  4. :: -- output should look like this: desktop-XXXxxxX\user
  5. :: -- this is your RDP_USER -- ::
  6.  
  7. @echo off
  8. setlocal enabledelayedexpansion
  9.  
  10. set TARGET_MAC=00-C0-CA-00-00-00
  11. set RDP_USER=DESKTOP\username
  12. :: -- USERNAME ABOVE: desktop-XXXxxxX\user
  13. set RDP_PASS=password
  14. :: -- PASSWORD USED TO LOGIN TO THE RDP COMPUTER user your desktop-XXXxxxX\user
  15.  
  16. REM find server IP from arp
  17. for /f "tokens=1,2" %%A in ('arp -a') do (
  18.     if /I "%%B"=="%TARGET_MAC%" (
  19.         set SERVER_IP=%%A
  20.     )
  21. )
  22.  
  23. if not defined SERVER_IP (
  24.     echo Server not found in ARP table.
  25.     pause
  26.     exit /b
  27. )
  28.  
  29. echo Server found at %SERVER_IP%
  30. echo Storing creds (cmdkey)...
  31.  
  32. REM Save credential for this host (TERMSRV/<IP>)
  33. cmdkey /generic:TERMSRV/%SERVER_IP% /user:%RDP_USER% /pass:%RDP_PASS%
  34.  
  35. echo Launching RDP...
  36. mstsc /v:%SERVER_IP% /admin
  37.  
  38. REM Optionally delete stored credential after RDP closes:
  39. echo Removing stored credential...
  40. cmdkey /delete:TERMSRV/%SERVER_IP%
  41.  
Advertisement