Everything in this batch script works fine, but when I enter the IF
statement, for some reason set /p id=
doesn't actually capture anything. In fact shortly after it will echo:
You chose session %id%.
but that will return a blank, as though nothing was entered for ID.
Any advice would be greatly appreciated.
@echo off
echo Please be sure CMD is being run as an administrator.
echo.
:loop
set /p targetpc="Which PC would you like to query for users (Hostname or IP)?: "
echo.
echo Querying %targetpc%...
echo.
quser /server:%targetpc%
echo.
set /p choice="Would you like to log a user off of %targetpc%? [Y/N]: "
echo.
IF /I "%choice%" EQU "Y" (
echo Enter user's session ID:
set /p id=
echo.
echo You chose session %id%.
echo.
logoff %id% /server:%targetpc% /V
echo.
echo Done!
echo.
goto loop
)
IF /I "%choice%" EQU "N" (
goto loop
)
Aucun commentaire:
Enregistrer un commentaire