[Windows] How to Restart / Shutdown machine use CMD prompt

**Restart**
C:\> shutdown.exe /m \\{FQDN或IP} /r /f /t 0 /c “add HOTFIX KBxxxxx"

**Shutdown**
C:\> shutdown.exe /m \\{FQDN或IP} /s /f /t 0 /c “face-out machine

**啟用互動式**
C:\> shutdown.exe /i
shutdown-i.jpg

 

(參數說明)
shutdown /[r|s] /m \\ComputerName /c “Comment" /d [u|p] <xx>:<yy>

Value Description
/r Restarts the remote computer.
/s Shuts down the remote computer.
/m \\ComputerName Specifies the destination computer.
/c “Comment Enables you to comment in detail about the reason for the shutdown. You can use a maximum of 511 characters. Comments must be enclosed in quotation marks.
/d [u|p] xx:yy Lists the reason for the system restart or shutdown, where xx specifies a major reason number from 0 through 255, and yy specifies a minor reason number from 0 through 65,535.
/force Forces the computer to shut down if other users are logged in. If this is not used and other users are logged in to the remote computer, the computer will not shut down or restart.

Important
If you force the computer to shut down or restart, logged in users will not have the opportunity to save their work.
/t xxx Sets the time-out period before the system shuts down or restarts to xxx seconds. The valid range is 0-600, with a default of 30. Using the /t flag implies the /force option.

[Windows] View Who Is Logged On Machine

method#1.
c:\> qwinsta.exe  /server:{FQDN或IP}

(參數)
顯示遠端桌面服務工作階段的資訊。

QUERY SESSION [sessionname | username | sessionid]
[/SERVER:servername] [/MODE] [/FLOW] [/CONNECT] [/COUNTER] [/VM]

sessionname 識別名稱為 sessionname 的工作階段。
username 以使用者 username 來識別工作階段。
sessionid 以識別碼 sessionid 來識別工作階段。
/SERVER:servername 要查詢的伺服器 (預設值是目前的伺服器)。
/MODE 顯示目前的線路設定值。
/FLOW 顯示目前的流量控制設定值。
/CONNECT 顯示目前的連線設定值。
/COUNTER 顯示目前遠端桌面服務計數器的資訊。
/VM 顯示虛擬機器中工作階段的相關資訊。

 

Method#2
c:\> query.exe /server:{FQDN或IP}

(參數)
QUERY { PROCESS | SESSION | TERMSERVER | USER }

Method#3 (GUI)
工作管理員 > 使用者