Windows XP 內建的 net 指令族群功能強大,遠不止基本的網路連線管理。本文挖掘 10 個鮮為人知的進階用法,涵蓋使用者帳號批次管理、服務遠端控制、共享資源稽核、時間同步、訊息廣播等實戰技巧,讓系統管理員事半功倍。
net user /add "TempUser" "P@ssw0rd" /expires:2024-12-31 /active:yes /passwordchg:no /passwordreq:yes
net localgroup "Users" "TempUser" /add
net accounts /maxpwage:90 /minpwlen:8 /uniquepw:5
/expires 設定帳號到期日,適合臨時帳號。/passwordchg:no 禁止使用者自行變更密碼。net accounts 設定全域密碼原則。net start "wuauserv" \\RemotePC
net stop "Spooler" \\RemotePC
net pause "EventLog" \\RemotePC
net continue "EventLog" \\RemotePC
需具備遠端電腦管理權限,且 RPC、防火牆允許遠端服務管理流量。
net share
net share "Data$=D:\Data" /grant:Everyone,READ /remark:"唯讀資料共享" /cache:none
net share "Admin$" /delete
net share 不帶參數列出所有共享(含隱藏共享 C$、ADMIN$、IPC$)。/cache:none 禁止離線快取,提升資料安全性。net time \\TimeServer /set /yes
w32tm /config /manualpeerlist:"time.windows.com,0x9" /syncfromflags:MANUAL /update
搭配排程工作每日同步,確保系統時間準確,對日誌稽核、Kerberos 驗證至關重要。
net send "All Users" "伺服器將於 10 分鐘後進行維護,請儲存檔案並登出。"
net send "SpecificUser" "您的列印作業已完成。"
注意:Messenger 服務有安全風險(垃圾訊息、緩衝區溢位),建議僅在受控內網短暫啟用,平時保持停用。
net file
net file 123 /close
查看遠端使用者開啟的本機檔案,必要時強制關閉(如備份前釋放鎖定檔案)。
net print \\PrintServer\PrinterName
net print \\PrintServer\PrinterName 5 /hold
net print \\PrintServer\PrinterName 5 /release
net print \\PrintServer\PrinterName 5 /delete
net config server /autodisconnect:15
net config workstation /charcount:1
for /f "tokens=1" %u in ('net user ^| findstr /v "The command\|User accounts\|-----"') do net user %u /scriptpath:"\\Server\NetLogon\%u.bat" /profilepath:"\\Server\Profiles\%u"
@echo off
set LOG=%~dp0NetAdmin_%date:~-4,4%%date:~4,2%%date:~7,2%.log
echo [%time%] Starting maintenance... >> %LOG%
net stop "wuauserv" >> %LOG% 2>&1
net start "wuauserv" >> %LOG% 2>&1
net time \\DC01 /set /yes >> %LOG% 2>&1
net share >> %LOG%
echo [%time%] Completed. >> %LOG%
net 指令是 Windows 內建最強大的網路管理工具組之一,熟練掌握其進階參數與組合技巧,能大幅減少對第三方管理工具的依賴,並在無圖形介面環境(如 Server Core、復原主控台、SSH 連線)下依然具備完整管理能力。