[研究]用netsh設定Windows防火牆攔截程式進出
2024-01-01
********************************************************************************
Block.cmd 範例
@REM Block.cmd netsh advfirewall firewall add rule name="program1.exe" dir=in action=block program="C:\Program Files (x86)\MyCompany\MyProduct\program1.exe" enable=yes profile=any netsh advfirewall firewall add rule name="program1.exe" dir=out action=block program="C:\Program Files (x86)\MyCompany\MyProduct\program1.exe" enable=yes profile=any netsh advfirewall firewall add rule name="program1.exe" dir=in action=block program="C:\Program Files\MyCompany\MyProduct\program1.exe" enable=yes profile=any netsh advfirewall firewall add rule name="program1.exe" dir=out action=block program="C:\Program Files\MyCompany\MyProduct\program1.exe" enable=yes profile=any |
netsh 參數
Microsoft Windows [版本 10.0.22621.2861]
(c) Microsoft Corporation. 著作權所有,並保留一切權利。
C:\Users\user1>netsh
netsh>
C:\Users\user1>netsh /?
使用方式: netsh [-a AliasFile] [-c Context] [-r RemoteMachine] [-u [DomainName\]UserName] [-p Password | *]
[Command | -f ScriptFile]
下列是所有可用的命令:
這個內容中的命令:
? - 顯示命令清單。
add - 新增項目清單中的設定項目。
advfirewall - 變更到 `netsh advfirewall' 內容。
branchcache - 變更到 `netsh branchcache' 內容。
bridge - 變更到 `netsh bridge' 內容。
delete - 刪除項目清單中的設定項目。
dhcpclient - 變更到 `netsh dhcpclient' 內容。
dnsclient - 變更到 `netsh dnsclient' 內容。
dump - 顯示設定指令檔。
exec - 執行指令檔。
firewall - 變更到 `netsh firewall' 內容。
help - 顯示命令清單。
http - 變更到 `netsh http' 內容。
interface - 變更到 `netsh interface' 內容。
ipsec - 變更到 `netsh ipsec' 內容。
lan - 變更到 `netsh lan' 內容。
mbn - 變更到 `netsh mbn' 內容。
namespace - 變更到 `netsh namespace' 內容。
netio - 變更到 `netsh netio' 內容。
nlm - 變更到 `netsh nlm' 內容。
p2p - 變更到 `netsh p2p' 內容。
ras - 變更到 `netsh ras' 內容。
rpc - 變更到 `netsh rpc' 內容。
set - 更新組態設定。
show - 顯示資訊。
trace - 變更到 `netsh trace' 內容。
wcn - 變更到 `netsh wcn' 內容。
wfp - 變更到 `netsh wfp' 內容。
winhttp - 變更到 `netsh winhttp' 內容。
winsock - 變更到 `netsh winsock' 內容。
wlan - 變更到 `netsh wlan' 內容。
下列是可使用的子內容:
advfirewall branchcache bridge dhcpclient dnsclient firewall http interface ipsec lan mbn namespace netio nlm p2p ras rpc trace wcn wfp winhttp winsock wlan
如果您要檢視命令的說明,請輸入該命令,後面接著一個空格,
然後輸入 ?。
C:\Users\user1>
|
(完)
相關
Netsh 命令語法、內容及格式設定 | Microsoft Learn
https://learn.microsoft.com/zh-tw/windows-server/networking/technologies/netsh/netsh-contexts
網路殼層 (Netsh) | Microsoft Learn
https://learn.microsoft.com/zh-tw/windows-server/networking/technologies/netsh/netsh
netsh | Microsoft Learn
https://learn.microsoft.com/zh-tw/windows-server/administration/windows-commands/netsh
沒有留言:
張貼留言