Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學

XP 中 Net 指令的另類用法:網路管理實戰技巧

編輯:Windows XP 系統介紹

Windows XP 內建的 net 指令族群功能強大,遠不止基本的網路連線管理。本文挖掘 10 個鮮為人知的進階用法,涵蓋使用者帳號批次管理、服務遠端控制、共享資源稽核、時間同步、訊息廣播等實戰技巧,讓系統管理員事半功倍。

1. 批次建立/管理使用者帳號

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 設定全域密碼原則。

2. 遠端服務控制

net start "wuauserv" \\RemotePC
net stop "Spooler" \\RemotePC
net pause "EventLog" \\RemotePC
net continue "EventLog" \\RemotePC

需具備遠端電腦管理權限,且 RPC、防火牆允許遠端服務管理流量。

3. 共享資源完整稽核

net share
net share "Data$=D:\Data" /grant:Everyone,READ /remark:"唯讀資料共享" /cache:none
net share "Admin$" /delete
  • net share 不帶參數列出所有共享(含隱藏共享 C$、ADMIN$、IPC$)。
  • /cache:none 禁止離線快取,提升資料安全性。

4. 網路時間同步(無需網域)

net time \\TimeServer /set /yes
w32tm /config /manualpeerlist:"time.windows.com,0x9" /syncfromflags:MANUAL /update

搭配排程工作每日同步,確保系統時間準確,對日誌稽核、Kerberos 驗證至關重要。

5. 訊息廣播(Messenger 服務需啟用)

net send "All Users" "伺服器將於 10 分鐘後進行維護,請儲存檔案並登出。"
net send "SpecificUser" "您的列印作業已完成。"

注意:Messenger 服務有安全風險(垃圾訊息、緩衝區溢位),建議僅在受控內網短暫啟用,平時保持停用。

6. 列出/中斷開啟的檔案連線

net file
net file 123 /close

查看遠端使用者開啟的本機檔案,必要時強制關閉(如備份前釋放鎖定檔案)。

7. 管理列印佇列

net print \\PrintServer\PrinterName
net print \\PrintServer\PrinterName 5 /hold
net print \\PrintServer\PrinterName 5 /release
net print \\PrintServer\PrinterName 5 /delete

8. 查看/設定網路介面綁定順序

net config server /autodisconnect:15
net config workstation /charcount:1

9. 批次修改登入腳本/設定檔路徑

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"

10. 結合批次檔實現自動化維護

@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 連線)下依然具備完整管理能力。

Copyright © Windows教程網 All Rights Reserved