dantpro

disconnect-rds-remotely

Jun 14th, 2017
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 1.31 KB | None | 0 0
  1. @ECHO OFF
  2. ::http://community.spiceworks.com/how_to/show/873
  3. ::https://community.spiceworks.com/scripts/show/190-disconnect-terminal-services-session-remotely
  4.  
  5. :WinVersion
  6. cls
  7. echo ## Definig Windows Version
  8. ver>"%temp%\ver.tmp"
  9. find /i "6.0" "%temp%\ver.tmp">nul
  10. if %ERRORLEVEL% EQU 0 goto ADMIN
  11. find /i "6.1" "%temp%\ver.tmp">nul
  12. if %ERRORLEVEL% EQU 0 goto ADMIN
  13.  
  14. :MENU1
  15. title Choose Server
  16. cls
  17. echo Enter Server name, IP address, or Q to quit.
  18. echo.
  19. set input=Z
  20.  
  21. :: Prompt for Install
  22. Set /P input=
  23. if /I %input% EQU Q goto END
  24. if /I %input% EQU Z goto MENU1
  25. set server=%input%
  26. goto USERS
  27.  
  28. :USERS
  29. title Users on %SERVER%
  30. cls
  31. qwinsta /server:%SERVER%
  32. echo.
  33. echo Type Session ID to disconnect session
  34. echo Type R to refresh user list
  35. echo Type P to choose another server
  36. echo Type Q to quit
  37. echo.
  38. set input=R
  39.  
  40. :: Prompt for Install
  41. Set /P input=
  42. if /I %input% EQU Q goto END
  43. if /I %input% EQU R goto USERS
  44. if /I %input% EQU P goto MENU1
  45. set session=%input%
  46. goto DISCON
  47.  
  48. :DISCON
  49. title Disconnecting User
  50. cls
  51. reset session %session% /server:%server%
  52. echo Log off in process
  53. echo .
  54. goto USERS
  55.  
  56. :ADMIN
  57. cls
  58. if /I %CD% EQU %systemroot%\system32 goto MENU1
  59. goto ERR1
  60.  
  61. :ERR1
  62. title Error
  63. cls
  64. echo This program requires Administrative Rights to run!
  65. echo.
  66. pause
  67. goto END
  68.  
  69. :END
  70. exit
Advertisement
Add Comment
Please, Sign In to add comment