Easily connect to an RDP shadow session. https://sagino-alchemia.org
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

ShadowSession.bat 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. @echo off
  2. setlocal enabledelayedexpansion
  3. :: Configuration
  4. set "csv_file=allowed_pcs.csv"
  5. :: Check if the policy file exists
  6. if not exist "%csv_file%" (
  7. echo [ERROR] %csv_file% not found.
  8. pause
  9. exit /b
  10. )
  11. echo ============================================
  12. echo Secure Shadow Session Menu (CSV Based)
  13. echo ============================================
  14. echo NO. : PC NAME : USER : DESC
  15. echo --------------------------------------------
  16. :: Read CSV and display the menu
  17. set count=0
  18. for /f "usebackq tokens=1-4 delims=," %%a in ("%csv_file%") do (
  19. set /a count+=1
  20. set "pc_!count!=%%a"
  21. set "user_!count!=%%b"
  22. set "id_!count!=%%c"
  23. echo [!count!] : %%a : %%b : %%d
  24. )
  25. echo.
  26. set /p choice="Select a number to connect (or 'q' to quit): "
  27. :: Handle exit or invalid input
  28. if /i "%choice%"=="q" exit /b
  29. if not defined pc_%choice% (
  30. echo [ERROR] Invalid selection.
  31. pause
  32. exit /b
  33. )
  34. :: Map selected ID to variables
  35. set "target_pc=!pc_%choice%!"
  36. set "allowed_user=!user_%choice%!"
  37. set "allowed_id=!id_%choice%!"
  38. echo.
  39. echo [INFO] Target PC: %target_pc%
  40. echo [INFO] Policy: User must be "%allowed_user%" with ID %allowed_id%
  41. echo Verifying remote session status...
  42. :: Verify the actual session status on the remote PC
  43. set "verified=false"
  44. for /f "tokens=1-4" %%i in ('qwinsta /server:%target_pc% ^| findstr /i "Active"') do (
  45. :: Check if the row contains both the allowed username and the specific session ID
  46. echo %%i %%j %%k %%l | findstr /i "%allowed_user%" | findstr "%allowed_id%" >nul
  47. if not errorlevel 1 (
  48. set "verified=true"
  49. )
  50. )
  51. :: Proceed if session matches the CSV policy
  52. if "%verified%"=="true" (
  53. echo [SUCCESS] Verification passed. Requesting connection...
  54. :: Note: /noConsentPrompt is omitted here. The user on the target PC must accept the request.
  55. mstsc /v:%target_pc% /shadow:%allowed_id% /control
  56. ) else (
  57. echo [SECURITY ALERT] Session verification failed.
  58. echo The current active user on %target_pc% does not match the CSV policy.
  59. )
  60. pause