When performing upgrades, I often need to logoff all users on a Windows server. Instead of logging into the server interactively and booting each one individually, this can be done remotely using a batch script.
setlocal enableextensions enabledelayedexpansion
set /a "x = 0"
if %x% leq 100 (
logoff %x% /server:ServerName /v
set /a "x = x + 1"
Replace “ServerName” with the name of the computer or server you wish to kick all users from. It will kick 100 users. You can of course replace the “100” with whatever number you’d like to use.
Of course, you must ensure you run it using an account that has admin rights to the server you are working with.