Windows 指令使用說明

1. 指令netstat說明

netstat <== 列出目前所有已連線IP連線狀態,外部IP以FQDN表示
netstat -n <==列出目前所有已連線IP連線狀態,IP以數字表示
netstat -an 5 <==列出目前所有的IP連線狀態,每5秒(5)更新一次
netstat -ano <==列出目前所有的IP連線狀態,以數字表示,並列出PID(o),可以確認該連線是由那個程序打開的
netstat -anb <==列出目前所有的IP連線狀態,並列出開啟的應用程式(b),可以確認該連線是由那個應用程式打開的
netstat -anp tcp <==只列出使用TCP協定的所有的IP連線狀態
netstat -ansp tcp <==列出tcp目前所有的IP連線狀態及TCP流量統計資料
netstat -e <==顯示網路卡流量統計
netstat -r <==顯示路由表
資料來源:http://bbs-mychat.com/reads.php?tid=836885,這裡有詳細的說明
補:在vista以上的版本,windows工作管理員預設不開啟 PID資料,請到檢視==>選擇欄位==>勾PID(程序識別元),就會出現,vista以上的工作管理員版本,有增加了很多欄位,方便管理員管理系統。

netstat -an | find 3389 <== 列出目前所有的IP連線狀態,並只列有關鍵字 3389
netstat -anp tcp | find ESTABLISHED <== 僅列出 TCP 目前所有的IP連線狀態,並只列有關鍵字 ESTABLISHED


2. 指令nbtstat

顯示通訊協定統計資料和目前使用 NBT (NetBIOS over TCP/IP) 的TCP/IP 連線
nbtstat -c 5 <==每5秒顯示本機的NetBIOS快取資料


3. regsvr32

DLL檔註冊指令
regsvr32 a.dll <==註冊a.dll
regsvr32 /u a.dll <==移除a.dll

補充:如果使用64bit的系統,則32bit的dll檔,請放在 /windowns/syswow64/中。64bit的dll檔,請放在 /windowns/system32/中


4. taskkill -- 終止處理程序的指令

taskkill /F /IM explorer.exe ==>使用Iamgename (IM) 強制終止(F) explorer.exe 程序
taskkill /F /PID 1500 ==>使用processid (PID) 強制終止explorer.exe 程序,PID不一定每一台電腦都相同,需要透過windows 工作管理員來查看


5. start -- 開啟另一個cmd 介面

start /wait /B explorer.exe ==>開啟另一個cmd 介面、等待(wait)上一個程式或命令完成後背景(B)執行 explorer.exe


6. chkntfs -- 開機時顯示或修正磁碟檢查
有時發生系統不斷chkdsk 時,可以透過這個指令關閉
chkntfs /x D: <==在預設開機檢查中排除(x)磁碟機檢查D碟


7. NET指令使用說明

帳號管理
net user ==>列出本機使用者
net user abc def /add ==>新增使用者abc,密碼為def,使用者群組預設為user
net user abc /del ==>刪除使用者abc
net user abc ==>本機使用者 abc 資訊
net user abc def /add /time:M-F,19:00-23:00;Sa-Su,6:00-22:00 ==>新增使用者abc,密碼為def,限制使用時間為週一~五晚上7:00~11:00,六日上午6:00~晚上10:00
net user abc abc123 ==>設定abc密碼為abc123(帳號需存在)
net localgroup users abc /add ==>將abc加入users群組
net user abc /active:no ==> 停用abc帳號

net user towns /domain ==> 查詢網域中 towns 帳號的資訊
net user /domain ==> 列出域中帳號
net user administrator ==> 列出域中 administrator 群組

相關資料來源:
http://ss64.com/nt/netuseroptions.html
http://tw.myblog.yahoo.com/starspc-exchange/article?mid=285
http://terrysnote.blogspot.com/2011/03/net.html

服務管理
用於管理系統中的服務,需打入服務名稱非顯示名稱
net start W3SVC==>啟動 World Wide Web Publishing Service 服務
net stop W3SVC==>停止 World Wide Web Publishing Service 服務系統服務
net start ==>列出已啟動的服務

遠端登入管理
net use abc abcde /user:town <== 登入主機abc(也可打入\\IP),密碼abcde,登入帳號 towns
net use <== 顯示目前登入的遠端資訊
net use /delete abc <== 刪除abc遠端登入
net use * /delete <== 刪除所有的遠端登入
net use abc /user:towns /smartcard <== 登入主機abc(也可打入\\IP),登入帳號 towns,使用 smartcard

共享資料匣管理
net share D:tools /delete <== 刪除D碟tools的共享
net share <== 查看本機目前共享資料匣的情形
net share D:tools <==建立D碟tools的共享
相關資料來源:
http://tw.group.knowledge.yahoo.com/hacker-cracker/article/view?aid=951

時間管理
net time \\192.168.1.5 /set /y <== 自動與192.168.1.5主機時間同步
net time \\192.168.1.5 <== 顯示192.168.1.5主機時間

網路芳鄰
net view <== 顯示區網中的主機

使用者密碼預設管理
net accounts /maxpwage:unlimited <== 設定所有帳號的密碼為無到期時間
net accounts <== 查看目前主機密碼的預設資料,並可以看到電腦用途
net accounts /domain

統計資料
net statistics <== 列出服務中可進行統計的資料
net statistics Server <== 列出Server 服務的統計資訊
net statistics workstation <== 列出workstation 服務的統計資訊
net config Server <== 可以看到軟體版、可登入數及可開啟檔案數

網路主機管理
net computer <== 顯示網路主機


8. netsh

用於管理網路介面的指令,與 cisco route 的指令使用方式相同(windows visat以上版本)
netsh int ipv4 show add <== 顯示所有介面中IPv4 的資訊,如介面名稱、IP、Netmask、gateway
netsh int ipv4 show conf <== 顯示所有介面的設定資訊
netsh int ipv4 show int <== 顯示所有介面卡資訊
netsh int ipv4 set add name="區域連線 2" static 192.168.7.2 255.255.255.0 192.168.7.1  10 <==設定區域連線2為手動設定 IP為192.168.7.2,Netmask 為255.255.255.0,gateway 為 192.168.7.1,gwmetric 為 10(無設定時為預設值256)
註:XP指令為 netsh int ip ......

名詞說明:閘道計量(gwmetric),閘道的優先順序,當我們設定兩張以上的網卡時(或拿windows做router時),這個設定值就非常重要了
相關資料:http://tw.myblog.yahoo.com/a-tion1020/article?mid=20

網路卡重新設定
netsh winsock reset

netsh int tcp show global <== 顯示全域參數
netsh int tcp set global timestamps=disabled <== 關閉 TCP 時間戳記
註:RFC 1323 時間戳記,這一個就是 TCP timestamps 漏洞

列出所有防火牆規則
netsh advfirewall firewall show rule name=all

參考資料:

BenIT 大文章
http://benit.pixnet.net/blog/post/66531732-win7--win10-%E9%9B%BB%E8%85%A6%E7%B6%B2%E5%8D%A1-reset-%E6%8C%87%E4%BB%A4

arstechnica 討論 -- Arbelac 回應
https://arstechnica.com/civis/viewtopic.php?t=1179027


9. robocopy

強大的備份指令,具有同步備份與差異備份的功能,取代 xcopy 無法有效進行同步備份的新指令
同步備份指令
robocopy  來源端  目的端  /e  /xo  /purge
例:robocopy d:\test e:\test /e /xo /purge ==>備份由 d:test 到 e:test,包涵子資料匣(/e)、來源端檔案較新時覆蓋目的端檔案(/xo)、來源端中無該檔時刪除目的端檔案(/purge)

有一個參數叫MIR,這個功能為 鏡像樹狀目 (相當於 /E 加 /PURGE),使用這個參數後,兩個資料匣的同步變的非常簡單
例:robocopy d:\test e:\test /mir
這個指令挺另人激賞的,使用的硬體資源少、備份速度也快,towns已經使用這個指令取代了SyncBack這套軟體,而UTF-8的問題也同時解決了

註1:使用robocopy,不需要加上start /wait,他會自己一條條執行
註2:使用 /mir 這個參數要小心,不然,會將目的地的檔案給刪了

相關資料:

pczone 討論
http://www.pczone.com.tw/vbb3/thread/3/115522/

dragonfly 大文章
https://blog.xuite.net/dragonfly_7252/computer/223236655-Robocopy+%E6%8C%87%E4%BB%A4%E7%AF%84%E4%BE%8B%E5%8F%83%E8%80%83+%28MIR%E5%95%8F%E9%A1%8C%E5%BE%88%E5%A4%9A%EF%BC%8C%E5%B0%8F%E5%BF%83%E4%BD%BF%E7%94%A8%29


10. 手動建立連結

vista、win 7
mklink /d winsxs d:winsxs 在該目錄下建立d:winsxs 目錄符號連結
mklink /j [產生連結的路徑] [來源路徑]

win XP、win 2000
junction

相關資料:
http://save-coco.blogspot.com/2010/05/windows-7.html 關於mklink有說明到
http://jdev.tw/blog/1242/mklink-junction-quick-folders-access 說明mklink及junction使用方式


11. tree 指令

顯示資料匣樹狀結構
tree d:temp /F > temp_tree.txt <== 以樹狀結構顯示 d:temp資料匣,顯示資料匣中的檔名,將資料輸出至tmep_tree.txt檔案中


12. tracert 指令

常用於網站不通時的查測,預設30個hop(跳躍點)
tracert tw.yahoo.com
詳細資料:http://technet.microsoft.com/en-us/library/cc940128.aspx

補充:windows 的tracert 指令,單純的使用ICMP、NetBIOS、DNS 來判斷路由器情形,與Linux 的traceroute的功能,差異非常大,所以使用 tracert 會有不少資訊找不到


13. pathping 指令

ping + tracert + 統計
詳細資料:http://technet.microsoft.com/zh-tw/library/cc787365%28v=ws.10%29.aspx


14. 系統路徑資料

系統匣路徑:%systemroot%
C:> cd %systemroot%
C:Windows>

使用者路徑:%userprofile%
C:> cd %userprofile%
C:Users[username]>

使用者路徑:%username% (vista以上版本可用)
C:>cd users%username%
C:Users[username]>


15. cacls 指令(可管理檔案、資料匣安全性)

相關資料:某前輩的資料
http://www.tank.tw/article/system/DOS%20%E4%BD%BF%E7%94%A8%E6%8C%87%E4%BB%A4%E8%AE%8A%E6%9B%B4Windows%E6%AA%94%E6%A1%88%E7%9A%84%E5%B1%AC%E6%80%A7%E5%8F%8A%E5%AE%89%E5%85%A8%E6%80%A7%20.htm


16. at 指令(排程指令)

在 linux 中,towns 非常常使用at 指令來定時執行單次動作,在 windows 中也有,來試試吧!

at <== 列出目前排程
at 05:00 2013-12-24 "c:windowssystem32shutdown.exe -s -f -t 10"<== 排定2013年12月24日上午5:00,執行強制關機動作
at 05:00 /every:M "c:windowssystem32shutdown.exe -r -f -t 10" <== 排定每週一上午5:00執行強制重新開機
at 05:00 "c:windowssystem32shutdown.exe -r -f -t 10" <== 今天上午5:00執行強制重新開機
at 1 /delete <== 刪除ID為1的排程工作(需先列出排程表,才能知道ID)
at <== 列出排程清單

資料來源:

Pejslin大的blog
http://pejslin.blogspot.tw/2011/12/windows-at.html

Jerry大的blog
http://jerryyang927.blogspot.tw/2008/09/windows-at.html

微軟官網
http://support.microsoft.com/kb/313565/zh-tw


17. find 指令
搜尋一或多個檔案中的文字字串。字串處理指令,類似Linux中的grep,可用於檔案及即時列出的資料

netstat -an |find /V "25" <== 列出不包含25字串的行
netstat -an |find "25" <== 列出包含25字串的行
netstat -an |find /C "25" <== 統計有25字串的行數
find "once" index.php <== 列出index.php檔中,有once字串的行
find /I "once" index.php <== 列出index.php檔中,有once字串的行,並忽略大小寫
find "once" *.php <== 列出目前路徑裡,所有php檔案中,有once字串的行

參考資料:Ader Chen 大的回應
http://www.blueshop.com.tw/board/show.asp?subcde=BRD20131220174341CFJ&fumcde=FUM20101016150225PC6#BRD2014032812021919X


18. rd 指令(取代deltree指令)

rd E:test /s /q <== 將e碟中test資料匣完全刪除(含所有內容)

資料來源:批次處理之家討論
http://www.bathome.net/thread-9267-1-1.html


19. nslookup指令

towns居然沒寫 = =

nslookup tw.yahoo.com <== 使用預設name server查詢yahoo的資訊
nslookup tw.yahoo.com dns.hinet.net <== 指定dns.hinet.net為name server,來查詢yahoo
nslookup 116.214.12.74 168.95.1.1 <== 使用IP查詢,同時也可以確認反解

nslookup <== 互動式查法
>?   <== 列出說明
> server 8.8.8.8 <== 連入google的name server
> set type=all <== 設定列出目前name server中的所有類型資訊
> set norec <== 關閉遞迴查詢。這時查詢domain資料,會從root name server開始查起,可用於DNS除錯
> set rec <== 開啟遞迴查詢。這是預設值

補充:nslookup 並不會確認所指定的 IP 是否有開放 53 port,也就是說使用 server 指令指定使用 IP,如果打錯了,只會出現無法查詢的訊息

參考資料:
pchome -- 指令教學
http://extra.pchome.com.tw/adm/faq_content02.htm?channel_no=MzkzMA==&exh_no=P000007&pexh_no=P000181&cexh_no=H000185&faq_id=327&qnum=1


20. ARP 指令

arp -a <== 顯示所有ARP快取
arp -d <== 刪除所有ARP快取
arp -s 192.168.56.90 08-00-7C-3B-FF <== 手動加入ARP快取

參考資料:
IT研究室
http://jaychu649.blogspot.tw/2015/06/arp-cache-clear-arp-entries-from.html


21. route 指令

route add 192.168.1.0 mask 255.255.255.0 192.168.2.2 metric 3 if 2 -p
192.168.1.0/24 的所有 IP,走 192.168.2.2 匣道,計量3,介面 2,重開後仍有效
註1:計量 是指優先順序
註2:介面 可從 route print 列出的 介面清單 看到

route delete 192.168.1.0 mask 255.255.255.0 192.168.2.2
刪除指定路由

圖型操作
開始 => 系統管理工具 => 路由及遠端存取 => IPv4 => 靜態路由

參考資料:
StackExchange 討論
https://serverfault.com/questions/510487/windows-get-the-interface-number-of-a-nic


22. DiskPart -- windows 中的 SPFdisk

towns 看了 linbty 大的 blog 後,覺得 DiskPart 與 SPFdisk 有相同之處,而且,對於 partition 的支援度更高了,而且全中文化,該好好學學這個工具了

diskpart /s F:CreatePartitions.txt <== 載入 diskpart 設定檔

diskpart <== 進入 DiskPart 工具
help <== 列出指令說明
help [指令] <== 列出子命令說明
active <== 將選取的磁碟分割標記為使用中
inactive <== 將選取的磁碟分割取標記為非使用中
assign <== 指派一個磁碟機代號或掛接點到選擇的磁碟區
assign letter="W" <== 指派 W 磁碟機代號或掛接點到選擇的磁碟區
remove <== 移除一個磁碟機代號或掛接點到選擇的磁碟區
remove letter="W"
list disk <== 顯示磁碟清單
selet disk [n] <== 選擇指定硬碟
detail disk <== 顯示指定硬碟詳細資料
list partition <== 顯示指定硬碟的分割表資料
select partition [n] <== 選擇指定的分割表資料
detail partition <== 顯示指定分割表詳細資料
list volume <== 顯示卷冊資料(這個會列出掛磁碟機代號)
clean <== 清除選定的磁碟資訊
create <== 建立磁碟


補充1:建立虛擬磁碟範例
這個範例是由 Windows VHD Onekey 工具產生的,towns 將他抄下來 ^^
create vdisk file="C:WIN10_VHD.VHD" maximum=15360 type=EXPANDABLE
select vdisk file="C:WIN10_VHD.VHD"
attach vdisk
create partition primaryassign letter=Z
format quick label=WIN10_VHD
exit

補充2:建立一個主要磁區
select disk 0
create partition primary <== 沒有指定空間,就是用到滿
select partition 1
active
format quick fs=ntfs

補充3:刪除磁區
select disk 0
select partition 1
delete partition

補充4:建碟一個 GPT 磁區並建立磁區
select disk 0
convert gpt
create partition primary
select partition 1
format quick fs=ntfs

補充5:清空第一個磁碟
select disk 0
clean

補充6:刪除 windows 10 產生的復原磁區
select disk 0
select partition [x] override

參考資料:
微軟說明
https://msdn.microsoft.com/zh-tw/library/hh825686.aspx

微軟指令範例:這個就是windows 10 安裝時預設使用的方式
https://msdn.microsoft.com/zh-tw/library/hh825686.aspx

amisay168 大文章 -- 修復磁碟分割區如何刪除?
http://blog.udn.com/amisay168/148855633


23. 批次檔(bat)設計

參考資料:
Alex 大的blog
http://alexchuo.blogsport.tw/2006/07/blog-pot.html 

Davidhu127 大的blog
http://davidhu0903ex3.pixnet.net/blog/post/443069270-%5B%E6%95%99%E5%AD%B8%5D-dos%E6%89%B9%E6%AC%A1%E6%AA%94%E8%A3%BD%E4%BD%9C---bat%E6%AA%94%E8%AA%9E%E6%B3%95

無尾熊大的 blog
http://koala.tw/bat%E6%89%B9%E6%AC%A1%E6%AA%94%E6%9C%80%E5%9F%BA%E7%A4%8E%E7%9A%8471%E5%80%8B%E6%8C%87%E4%BB%A4/


24. shutdown 指令

這個指令從 xp 開始就有使用了,不過從沒想到,有這麼多功能,towns 來列一下

shutdown /i <== 開啟圖型介面
shutdown /l <== 登出系統
shutdown /s /t 30 <== 30秒後關閉系統
shutdown /s /f /t 30 <== 30秒後強制關閉系統
shutdown /r /t 20 <== 20秒後重新啟動系統
shutdown /g /t 20 <== 20秒後重新啟動系統,並於重開啟動原執行程式
shutdown /a <== 中止系統關機
shutdown /p <== 立刻強制關機
shutdown /h /t 20 <== 20秒後系統休眠,會跳出提示
shutdown /s /m [電腦名稱] <== 關閉遠端主機(有條件執行)
註1:當有下 t 參數設定時間,則隱含 f 參數功能
註2:參數 /c 重新啟動、關關的註解
註3:參數 /d 重新啟動、關關的理由(就是執行關機時出現的選項)

參考資料:
微軟的help
iT邦幫忙 -- deargrass 文章
http://ithelp.ithome.com.tw/articles/10034335 


25. bcdedit 指令

BCDEDIT - 開機設定資料存放區編輯器

bcdedit /set hypervisorlaunchtype off <= 關閉 hyper-v 預設啟動
bcdedit /set hypervisorlaunchtype auto <= 預設值 hyper-v 為自動
bcdedit /enum <= 列出目前 開機管理程式 及 開機載入器 的項目

全中文化說明 ^^
參考資料:
官方說明 -- BCDEdit 命令列選項
https://docs.microsoft.com/zh-tw/windows-hardware/manufacture/desktop/bcdedit-command-line-options

官方說明 -- BCDEdit /set
https://docs.microsoft.com/en-us/windows-hardware/drivers/devtest/bcdedit--set


26. bootrec 指令

這個指令只會出現在救援光碟、安裝光碟、winpe 中,主要的功能為修復系統的開機資訊

bootrec /fixmbr <== 修復、重建 MBR 磁區
bootrec /fixboot <== 修復、重建 boot 資料匣
bootrec /scanos <== 掃瞄所有磁區,並顯示目前不在開機設定存放區中的項目
bootrec /rebuildbcd <== 掃瞄所有磁區,並同意使用者指定關機資訊存放位置

補充1:常會與 diskpart 聯用
補充2:如果在使用 bootrec /fixboot 出現“找不到元素”,可能是因為磁區沒有設定 active 造成,就用 diskprt 協助建立吧!


27. bcdboot 指令(win 8)

這個指令可以重建重要的開機檔案,並建立 BCD 資料匣

Bcdboot C:Windows /s C: /f UEFI <== 指定使用 C:Windows,指定使用 UEFI 模式
Bcdboot C:windows /l zh-TW <== 初始化 BCD 存放區,並指定使用繁中

Bcdboot C:Windows /s C: /f BIOS /l zh-TW <== 指定使用 MBR 模式

補充1:win 7 與 win 8 的 bcdboot 版本不同。win 7 參數只有 l、s、v、m,win 8 有 l、s、v、m、d、f、addlast 七個參數
補充2:指定使用模式的參數 /f ,可以使用 ALL 這是否是說,EFI 及 MBR 模式,兩者可以併存。在towns 的想法中,應該是可以的,因為,只是多了資料匣而以。測試結果是不行 = =,不是每個隨身碟都可以使用 MBR 模式來開機

參考資料:
華碩常見問題
https://www.asus.com/tw/support/faq/1011477

T 客邦 -- 大容量硬碟、UEFI 系統進階玩法
http://www.techbang.com/posts/14126-gpt-mbr-non-destructive-easily-split-format-conversion-between 


28. convert 指令

早期在 XP 年代時常用的指令

convert E: /FS:NTFS <== 將 E 碟檔案系統轉成 NTFS 格式
通常轉換檔案系統,需要卸載檔案系統,通常會重開系通後排程轉換

參考資料:梅問題教學網
http://www.minwt.com/pc/421.html 


29. portqry 指令

其實這個不能算是指令,而是一個微軟的 port 掃瞄工具,可以用來偵測主機有開放哪些 Port,有點類似 Nmap(Nmap更強大啦!) 這類的工具,不過,用這個軟體掃瞄其他主機的 port 可能不好,掃瞄自己的就好了 ^^

portqry -n test.com.tw -p tcp -e 25 ==> -n 網址或 IP,-p 協定,-e 單一port(-e endpoint)
portqry -n 192.168.1.201 -p tcp -r 800:1000 -l portqry.txt(-r range,-l logfile)
portqry -n 192.168.1.201 -p tcp -o 80,443,110(-o order)
portqry -n 192.168.1.201 -p udp -e 21
portqry -n 192.168.1.201 -p tcp -r 800:1000 -q 1 -l portqry.txt(-q quite,0 listening,1 not listening,2 listening or filtered)
portqry -n  192.168.1.201 -p both -e 21

參考資料:
Aeolu 大的文章
http://forum.ipb.tw/index.php?showtopic=23649
微軟下載處
http://www.microsoft.com/en-us/download/details.aspx?id=17148

微軟範例
https://support.microsoft.com/en-us/kb/310099


30. Pstools 微軟工具包(未完成)

這個就一定不是指令了,工具包嘛。內含以下工具,而且也有自帶說明文件哦!

PsExec - execute processes remotely(執行程序追蹤)
PsFile - shows files opened remotely(檔案開啟追蹤)
PsGetSid - display the SID of a computer or a user(顯示本機或使用者的 SID)
PsInfo - list information about a system
PsKill - kill processes by name or process ID
PsList - list detailed information about processes
PsLoggedOn - see who's logged on locally and via resource sharing
PsLogList - dump event log records
PsPasswd - changes account passwords
PsPing - test network performance
PsService - view and control services
PsShutdown - shuts down and optionally reboots a computer
PsSuspend - suspend and resume processes

參考資料:Pstools.chm 說明文件


31. 快速執行說明

收集了很多快速執行資料,感謝大大

taskmgr|工作管理員(Windows 2000/XP/2003/win 7/win 10)
devmgmt|裝置管理員(Windows 2000/XP/2003/win 7/win 10)
compmgmt.msc|電腦管理(Windows 2000/XP/2003/win 7/win 10)
services.msc|本機服務設定(Windows 2000/XP/2003/win 7/win 10)
secpol.msc | 本機安全性原則(win 7/win 10 企業版、教育版等以上版本)
taskschd.msc | 工作排程器
eventvwr.msc | 事件檢視器
lusrmgr.msc | 本機帳號管理器
lsdiag.msc | 遠端桌面授權診斷程式
licmgr.exe | 遠端桌面授權管理員

參考資料:寂寞愛大的blog
http://w-nison.blogspot.tw/2010/09/windows.html 


32. windows 指令大全

w-nison 大所寫的是執行應用程式,很方便呢! ^^

參考資料:w-nison 大的blog
http://w-nison.blogspot.tw/2010/09/windows.html 


33. wmic(Windows Management Instrumentation Command-line) 工具(win 7、10)

在指令模式下的一個工具。可以簡化查詢資料的方式,一個非常方便工具

使用方式:1.開啟 cmd、2.打入 wmic、3. 查看說明 /?

例:列出系統有安裝簡單資訊
wmic product list brief

也可直接輸入

例:顯示 CPU 簡單資訊
wmic cpu list brief

註:現在有很多的 OS 都開始使用這樣的模式來下指令(如 CISCO 的設備、CentOS7等…)

wmic service where state="Running" get DisplayName, Caption => 檢查執行中的服務
wmic startup list brief => 檢查開機啟動資訊
wmic share list brief => net share
wmic qfe get /ALL => 列出系統更新狀態
wmic useraccount where Disabled=FALSE get Description, Name, PasswordExpires, PasswordRequired => 列出帳號資料
wmic logicaldisk get VolumeName, Caption, FileSystem => 列出磁碟資料
wmic nicconfig get Description, IpAddress => 列出網路卡資料
wmic computersystem get Domain, Name => 列出本資料(Domain, Name)

參考資料:
Johnny 大的 blog
http://johnny0627.blogspot.tw/2014/03/wmic-rd.html

簡大的 blog
http://jdev.tw/blog/2487/wmic-product 


34. systeminfo(win 7、10)

此工具可顯示本機或遠端機器的作業系統設定資訊

systeminfo 這個指令可以列出大多數硬體資訊、OS資訊及BIOS資訊

這兩個指令可以合用,如果需要簡單資訊 systeminfo 就可以看到,如果要指定某晶片(如CPU),可以使用 wmic 列出 

iT邦幫忙討論串
https://ithelp.ithome.com.tw/questions/10002871


35. log parser -- windows 的 log 分析工具(未完成)

1. 取得,到微軟取得檔案
http://www.weithenn.org/2009/05/windows-xp-log-parser.html

2. 安裝 LogParser.msi

3.

註:可以用在 win2k8R2、win 7

參考資料:
Wang Wei-Jen 大的 blog
http://www.weithenn.org/2009/05/windows-xp-log-parser.html

保哥
https://blog.miniasp.com/post/2008/10/02/Useful-tool-Powerful-Log-Parser.aspx

微軟
https://technet.microsoft.com/zh-tw/scriptcenter/dd919274.aspx 


36. ipconfig

ipconifig /flushdns <== 清除 DNS 快取

ipconfig /displaydns <== 查看 DNS 快取


37. dir

dir /OD <== 依日期排序 


38. attrib 顯示或變更檔案屬性

微軟已經寫的相當清楚了,參數說明就用 /? 看哦!

attrib +r +h towns.txt <== 將該檔案加入唯讀及隱藏屬性

ATTRIB [+R | -R] [+A | -A] [+S | -S] [+H | -H] [+O | -O] [+I | -I] [+P | -P] [+U | -U]
       [磁碟機:][路徑][檔案名稱] [/S [/D]] [/L] 


39. 時間校時指令 w32tm

 

參考資料:保哥文章
https://blog.miniasp.com/post/2009/06/16/Configure-the-Windows-Time-service-on-the-Domain-Controller.aspx 


40. 憑證管理指令 CertUtil

 


41. 群組原則立即套用指令 gpupdate

gpupdate /force <= 重新套用所有原則,預設值是只套用被變更過的原則

 


42. 列出 cmd 所執行過的指令

doskey /h

參考資料:Technet 討論 -- YCTAM 回應
https://social.technet.microsoft.com/Forums/zh-TW/a563d7a5-3e93-428b-8034-b2857458c53a/25351201962251934892303402751121490353523763626597354262604127?forum=winserverzhcht  


43. 傳送訊息給使用者指令 msg(win 10)

這個是可以在本機傳訊息,也可以透過網路傳訊息的

msg towns /W test <== 由本機傳送訊息給 towns

註:要透過網路傳送需將
HKLMSYSTEMCurrentControlSetControlTerminal Server"右方的 AllowRemoteRPC 值要為1

參考資料:
CSSTWPlatform 大的文章
https://blogs.technet.microsoft.com/csstwplatform/2011/03/30/msg-exe/  


44. windows 下的 grup 指令 -- findstr

大家可能都知道 linux 下有 grup 這個文字處理指令,在 windows 下也有類似的指令,就是 findstr,下面會留下 towns 的使用紀錄

type [filename] | findstr /I /C:[字串] > abc.txt => 顯示檔案內容後將特定字寫入 abc.txt 中
findstr /v "0" source.txt > target.txt => 將特定檔案中有含 0 的行忽略,其他寫入 target.txt 中

參考資料:
阿彬大的 blog
http://huangsb.blogspot.com/2010/03/windows-grep-findstr.html

It邦幫忙 -- 海綿大回應
https://ithelp.ithome.com.tw/questions/10083271

adald 大文章
http://adalf0722.blogspot.com/2009/02/findstr.html  


45. gpresult

gpresult /scope computer /Z <= 這個指令會取出 GPO 的資料

 


46. reg

reg query [機碼路徑] <= 讓系統列出指定機碼資料

 


secedit /export /cfg
auditpol /get /category:* <= 列出系統設定的操作稽核項目
ver <= 顯示 windows 版本

 


regedit /s ***.reg

透過指令執行 reg 檔

留言

這個網誌中的熱門文章

zimbra 安裝、管理、設定

Fortigate 100D -- 管理、設定

IT 隨手記6