網頁

2011年2月17日 星期四

Windows 指令

netstat 顯示出電腦當前所開放的埠號
NETSTAT [-a] [-b] [-e] [-n] [-o] [-p proto] [-r] [-s] [-v] [interval]
  -a            Displays all connections and listening ports.
  -n            Displays addresses and port numbers in numerical form.
  -o            Displays the owning process ID associated with each connection.
  interval      Redisplays selected statistics, pausing interval seconds
                between each display.  Press CTRL+C to stop redisplaying
                statistics.  If omitted, netstat will print the current
                configuration information once.
EX:netstat -nao 1

regsvr32 登錄和取消登錄OLE 控制項
regsvr32 [-u] [-s] [-n] [-i[:cmdline]] dllname
  -u            解除登錄伺服器
  -s            無訊息;不顯示訊息方塊
  -i            呼叫DllInstall將選項傳給它[cmdline];與-u一起使用時,呼叫dll進行解除安裝
  -n            不要呼叫DllRegisterServer;這個選項必須與-i一起使用
EX:regsvr32 /u a.dll

net 可以用來帳戶原則、使用者、群組、等共用上執行作業
NET [ ACCOUNTS | COMPUTER | CONFIG | CONTINUE | FILE | GROUP | HELP |
      HELPMSG | LOCALGROUP | NAME | PAUSE | PRINT | SEND | SESSION |
      SHARE | START | STATISTICS | STOP | TIME | USE | USER | VIEW ]
NET START [SERVICE]
NET STOP  [SERVICE]
NET USE
[devicename | *] [\\computername\sharename[\volume] [password | *]]
        [/USER:[domainname\]username]
        [/USER:[dotted domain name\]username]
        [/USER:[username@dotted domain name]
        [/SMARTCARD]
        [/SAVECRED]
        [[/DELETE] | [/PERSISTENT:{YES | NO}]]
NET USE {devicename | *} [password | *] /HOME
NET USE [/PERSISTENT:{YES | NO}]
EX:
net stop server <==停用SERVER服務(透過網路為這台電腦提供檔案、列印、及具名管道的共用)
net use g: \\10.10.10.10\test password /user:testdomain\momo
   (登入10.10.10.10,設為G曹,密碼password,帳號testdomain\momo)
net use g: /delete  <==移除網路磁碟G槽

netsh 相關網路設定
netsh [-a AliasFile] [-c Context] [-r RemoteMachine]
                [Command | -f ScriptFile]
?              - 顯示命令清單。
add            - 新增項目清單中的設定項目。
bridge         - 變更到 `netsh bridge' 內容。
delete         - 刪除項目清單中的設定項目。
diag           - 變更到 `netsh diag' 內容。
dump           - 顯示設定指令檔。
exec           - 執行指令檔。
firewall       - 變更到 `netsh firewall' 內容。
help           - 顯示命令清單。
interface      - 變更到 `netsh interface' 內容。
lan            - 變更到 `netsh lan' 內容。
ras            - 變更到 `netsh ras' 內容。
routing        - 變更到 `netsh routing' 內容。
set            - 更新組態設定。
show           - 顯示資訊。
winsock        - 變更到 `netsh winsock' 內容。
下列是可使用的子內容:
 bridge diag firewall interface lan ras routing winsock
EX:
netsh firewall delete portopening TCP 80  <==移除防火牆設定的80 PORT
netsh firewall delete allowedprogram C:\MyApp\MyApp.exe  <==移除防火牆設定的程式
netsh interface ip set address name="區域連線" static 10.10.10.10 255.255.255.0 10.10.10.254 1netsh interface ip set dns name="區域連線" static 168.95.1.1

ping 使用Ping測試連線
ping [-t] [-a] [-n count] [-l size] [-f] [-i TTL] [-v TOS]
     [-r count] [-s count] [[-j host-list] | [-k host-list]]
     [-w timeout] target_name
    -t             Ping the specified host until stopped.
    -n count       Number of echo requests to send.
    -l size        Send buffer size.(byte)(0-65500)
EX:ping 168.95.1.1 -t -l 1024  <==1MB封包

nslookup 網域名稱解析查詢
EX:
C:\>nslookup
Default Server:  X.Y.com.tw
Address:  10.10.10.1
> server 168.95.1.1
Default Server:  dns.hinet.net
Address:  168.95.1.1
> www.hinet.net
Server:  dns.hinet.net
Address:  168.95.1.1
Non-authoritative answer:
Name:    www.hinet.net
Addresses:  203.66.88.89, 61.219.38.89
> exit

arp 使用Arp解決硬體位址問題
ARP -s inet_addr eth_addr [if_addr]
ARP -d inet_addr [if_addr]
ARP -a [inet_addr] [-N if_addr]
  -a            Displays current ARP entries by interrogating the current
                protocol data.  If inet_addr is specified, the IP and Physical
                addresses for only the specified computer are displayed.  If
                more than one network interface uses ARP, entries for each ARP
                table are displayed.
  -d            Deletes the host specified by inet_addr. inet_addr may be
                wildcarded with * to delete all hosts.
  -s            Adds the host and associates the Internet address inet_addr
                with the Physical address eth_addr.  The Physical address is
                given as 6 hexadecimal bytes separated by hyphens. The entry
                is permanent.     
EX:
arp -s 157.55.85.212   00-aa-00-62-c6-09   <==增加靜態ARP
arp -a                                                             <==顯示所有ARP列表

tracert 使用tracert跟蹤網路連接
tracert [-d] [-h maximum_hops] [-j host-list] [-w timeout] target_name
EX:
c:\>tracert 168.95.1.1
Tracing route to dns.hinet.net [168.95.1.1]
over a maximum of 30 hops:
  1    <1 ms    <1 ms    <1 ms  x.x.x.x
  2     1 ms    <1 ms    <1 ms  y.y.y.y
  3    86 ms   107 ms    22 ms  h254.s98.ts.hinet.net [168.95.98.254]
  4    52 ms    40 ms    62 ms  tpn2-3102.hinet.net [168.95.163.78]
  5    67 ms    25 ms    21 ms  tpdt-3012.hinet.net [220.128.4.122]
  6   112 ms    32 ms    19 ms  TPDB-3102.hinet.net [220.128.2.217]
  7    37 ms    55 ms    41 ms  210-59-204-189.HINET-IP.hinet.net [210.59.204.189]
  8    37 ms    24 ms    37 ms  dns.hinet.net [168.95.1.1]
Trace complete.

ipconfig 使用ipconfig檢視配置
ipconfig [/? | /all | /renew [adapter] | /release [adapter] | /flushdns | /displaydns | /registerdns | /showclassid
             adapter | /setclassid adapter [classid] ]
   /all         Display full configuration information.(顯示所有設定資訊)
   /release     Release the IP address for the specified adapter.(釋放網卡DHCP IP)
   /renew       Renew the IP address for the specified adapter.(更新網卡DHCP IP)
   /flushdns    Purges the DNS Resolver cache.(清除NDS解析暫存資訊)
   /registerdns Refreshes all DHCP leases and re-registers DNS names(重新註冊DNS名稱)
   /displaydns  Display the contents of the DNS Resolver Cache.(顯示DNS解析暫存資訊)
EX:
ipconfig /release            <==釋放DHCP IP
ipconfig /renew             <==重新取得DHCP IP
ipconfig /flushdns          <==清除DNS暫存資料
ipconfig /registerdns      <==重新註冊DNS名稱

shutdown 相關關機指令
shutdown [-i | -l | -s | -r | -a] [-f] [-m file://computername/] [-t xx] [-c "comment"] [-d up:xx:yy]
        沒有引數                顯示這個訊息 (和 -? 相同)
        -i                      顯示 GUI 介面,必須是第一個選項
        -l                      登出 (不能和 -m 選項一起使用)
        -s                      電腦關機
        -r                      關機並重新啟動電腦
        -a                      中止系統關機
        -m \\\\computername     從遠端進行關機/重新啟動/中止
        -t xx                   將關機等候時間設定成 xx 秒
        -c "comment"            關機註解 (最多 127 個字元)
        -f                      強制關閉執行中的應用程式,不顯示警告
        -d [u][p]:xx:yy         關機原因代碼
                                u 是使用者代碼
                                p 是預先計劃的關機代碼
                                xx 是主要原因代碼 (小於 256 的正整數)
                                yy 是次要原因代碼 (小於 65536 的正整數)
EX:
shutdown -s -f -t 5    <==5秒後立即強制關機
shutdown -r -t 600    <==10分鐘後重新啟動
shhutdown -a            <==中止關機,下錯關機指令時可馬上使用

route 本機路由設定、列表
ROUTE [-f] [-p] [command [destination]
                  [MASK netmask]  [gateway] [METRIC metric]  [IF interface]
  -p           永久,不因重啟而消失
command      One of these:
                 PRINT     Prints  a route
                 ADD       Adds    a route
                 DELETE    Deletes a route
                 CHANGE    Modifies an existing route
EX
    > route PRINT
    > route ADD 157.0.0.0 MASK 255.0.0.0  157.55.80.1 METRIC 3 IF 2
             destination^      ^mask      ^gateway     metric^    ^
                                                         Interface^
      If IF is not given, it tries to find the best interface for a given
      gateway.
    > route PRINT
    > route PRINT
    > route DELETE 157.0.0.0
    > route PRINT    
EX:
route printroute add 192.168.10.0 mask 255.255.255.0 10.10.10.2 -Proute delete 192.168.10.0

convert 磁碟檔案格式轉換
CONVERT volume /FS:NTFS [/V] [/CvtArea:filename] [/NoSecurity] [/X]
volume 指定磁碟機代號 (後接冒號),掛接點或磁碟區名稱。
  /FS:NTFS 指定將磁碟區轉換成 NTFS。
  /V 指定在詳細訊息模式下執行轉換。
  /CvtArea:filename 在根目錄中指定一個相連的檔案作為NTFS 系統檔案的置放點。
  /NoSecurity 指定已轉換的檔案和目錄的安全性設定值能讓每個人存取。
  /X 必要的話,強迫磁碟區先卸下。所有已開啟的磁碟區控制碼將失效。
EX:convert d: /FS:NTFS /V  <==轉換D槽檔案格式並顯示訊息

gpupdate 更新群組原則設定。
GPUpdate [/Target:{Computer | User}] [/Force] [/Wait:<value>] [/Logoff] [/Boot] [/Sync]
  /Force                    重新套用所有原則設定。預設值是只套用被變更過的原則設定。
EX:gpupdate /force

net time 當電腦系統的時間與DC相差超過五分鐘以上時,則該電腦會發生無法登入的問題,此時可以採用GPO(網域群組原則)來制定網域內主機的Time Server,如果需要馬上校正時間則可以採用下列的指令來校正時間。
NET TIME
[\\computername | /DOMAIN[:domainname] | /RTSDOMAIN[:domainname]] [/SET]
         [\\computername] /QUERYSNTP
         [\\computername] /SETSNTP[:ntp server list]
NET TIME 可以與另一部電腦或網域的時鐘同步,或者顯示電腦或網域的時間。如果 Windows Server 網域上不使用選項,它會顯示該網域的時間伺服器電腦上目前的日期和時間。這個指令可以讓您設定 computername的 NTP timeserver。
file://computername/ 你所要檢查或同步化的電腦名稱。
/DOMAIN[:domainname] 指定在 domainname 中要與其時間同步化的網域主控制站。
/RTSDOMAIN[:domainname] 指定要與 domainname 中的Reliable Time Server 時間同步化
/SET 將電腦時間與指定的電腦或網域上的時間同步化。
/QUERYSNTP 顯示這台電腦目前設定的 NTP 伺服器。
/SETSNTP[:ntp server list]
設定這台電腦所使用的 NTP 時間伺服器。可能是一份用空格分隔的 IP 位址清單或 DNS 名稱清單。
如果清單中有數個 timeservers ,請用雙引號將清單括住。

WSUS 3.0 (Windows Server Update Services )
#向WSUS主機註冊流程
wuauclt.exe /resetauthorization
#完成註冊後馬上套用新的規則並且向 WSUS 主機檢查更新
net stop wuauserv
net start wuauserv
wuauclt.exe /detectnow


w32tm 進行時間同步
w32tm /config [/computer:<target>] [/update] [/manualpeerlist:<peers>] [/syncfromflags:<source>]
      [/LocalClockDispersion:<seconds>]
  computer:<target> - 調整 <target> 設定。如果並未指定,預設值是本機電腦。
  update - 將設定變更通知時間服務,這樣變更才會生效。
  manualpeerlist:<peers> - 設定 <peers> 的手動對等清單,這是用空格分隔的 DNS 及 (或) IP 位址清單。在指定數個同級電腦時,這個參數必須用引號括住電腦清單。
  syncfromflags:<source> - 設定 NTP 用戶端應該使用的同步處理來源。<source> 應該是個用逗號分隔的關鍵字清單 (不區分大小寫),包括:
      MANUAL - 包含從手動對等清單中的對等項目
      DOMHIER - 從網域階層 DC 進行同步處理
EX:
w32tm /config /manualpeerlist:"tick.stdtime.gov.tw,clock.stdtime.gov.tw" /syncfromflags:manual /reliable:yes /update


參考、資料來源:
來吧~~~電腦 http://itgroup.blueshop.com.tw/towns/hc?n=wodvew&i=378
MIS技術交流論壇 http://220.132.221.128/viewthread.php?tid=1876
Gary 的 MIS 生涯  http://blog.roodo.com/gary0108/archives/cat_367631.html
內建cmdline help

沒有留言:

張貼留言