문제

We have domain users that use a remote instance of an app through RDP. The app is quite buggy, and their session needs reset frequently. I'd like to build a script that uses psexec from the client to reset the session on the server.

psexec \\server -u user -p pass query session

shows all the sessions

psexec \\server -u user -p pass reset session_id

resets the session based upon the id.

I need a way to reset the session based upon the username, instead of session name or id

도움이 되었습니까?

해결책

Try this combination of commands to get the username and then you can kill the session by id. You will need PsLoggedOn from Windows Sysinternals Here is the a link which explains the commands. How to check who has logged into your system

PSLOGGEDON -L \\remotecomputeror 

PSEXEC \\remotecomputer NET CONFIG WORKSTATION | FIND /I " name "

PSEXEC \\remotecomputer NET NAME

PSEXEC \\remotecomputer NETSH DIAG SHOW COMPUTER /V | FIND /i "username" 

FOR /F %%A IN ('REG Query \\remotecomputer\HKU ˆ| FINDSTR /R /B /C:"HKEY_USERS\\S-1-5-[0-9][0-9]-[0-9-]*$"') DO ( 
FOR /F "tokens=3 delims=\" %%B IN ('REG Query "\\remotecomputer\%%A\Volatile Environment"') DO ( 
SET LoggedinUser=%%B 
) 
) 
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top