史萊姆論壇

史萊姆論壇 (http://forum.slime.com.tw/)
-   網路軟硬體架設技術文件 (http://forum.slime.com.tw/f133.html)
-   -   用命令的指令行重啟網路卡和網路連接? (http://forum.slime.com.tw/thread77936.html)

psac 2003-10-22 03:37 PM

用命令的指令行重啟網路卡和網路連接?
 
Q:
家裡上網,因寬帶公司將IP和mac位址元件服務,經常需要切換ip位址和網路卡mac位址
我將MAC位址的註冊表匯出來,做成批次處理,
但是每次都需要先禁用,再啟用本機連接才能生效,有沒有指令行重啟網路卡和網路連接,這樣就可用批次處理自動切換網路卡ip和mac位址了
系統win2003
我試過ipchang2.0 和筆記型IP切換器等軟體,都不能切換MAC位址,只能切換IP
用net stop "Network Connections"
net start "Network Connections"
也不起作用 ................

A:
Win2k中用指令行設定IP位址,在2003中應該也可以使用吧:
制作備份設定
netsh -c interface dump > config.txt

恢復設定
netsh -f config.txt

netsh -f 這個只是制作備份、恢復網路卡IP位址,沒涉及到mac位址......

使用ms ddk 的 工具 devcon
我一直用 它,
下面的指令 可以重新 啟動 所有的pci網路卡
devcon.exe restart =net pci\*
我的win2k 用起來很好
win2k3 也沒問題
我的指令碼文件
regedit /s mac.reg
devcon.exe restart =net pci\*
C:\i386>devcon.exe restart =net pci\*
PCI\VEN_1106&DEV_3043&SUBSYS_14001186&REV_06\3&61AAA01&0&50 : Restarted
1 device(s) restarted.

C:\i386>devcon.exe disable =net pci\*
PCI\VEN_1106&DEV_3043&SUBSYS_14001186&REV_06\3&61AAA01&0&50 : Disabled
1 device(s) disabled.

C:\i386>devcon.exe enable =net pci\*
PCI\VEN_1106&DEV_3043&SUBSYS_14001186&REV_06\3&61AAA01&0&50 : Enabled
1 device(s) enabled.

C:\i386>ver

Microsoft Windows [Version 5.2.3790]

C:\i386>

附件 是 最新i386 版本的 devcon
原文見 devcon.exe
http://support.microsoft.com/?kbid=311272

FILE: DevCon Command Line Utility Alternative to Device Manager
View products that this article applies to.
This article was previously published under Q311272
SUMMARY
The DevCon utility is a command line utility that acts as an alternative to Device Manager. Using DevCon, you can enable, disable, restart, update, remove, and query individual devices or groups of devices. DevCon provides information that is relevant to the developer and is not available in Device Manager.

You can use DevCon with Windows 2000 and Windows XP. You cannot use Devcon with Microsoft Windows 95, Windows 98, or Windows Millennium Edition.
MORE INFORMATION
DevCon is not redistributable. It is provided for use as a debugging and development tool. You can freely modify DevCon for private use. The sample demonstrates how to use the SetupAPI and CfgMgr32 functions together effectively to enumerate devices and perform device operations. The following file is available for download from the Microsoft Download Center:

Download the DevCon package now. Release Date: Jan-29-2003

For additional information about how to download Microsoft Support files, click the following article number to view the article in the Microsoft Knowledge Base:
119591 How to Obtain Microsoft Support Files from Online Services

Microsoft scanned this file for viruses. Microsoft used the most current virus-detection software that was available on the date that the file was posted. The file is stored on security-enhanced servers that help to prevent any unauthorized changes to the file.

The DevCon.exe file contains the following files:
File Description
I386\DevCon.exe 32-bit DevCon tool binary. This will not function completely on 64-bit Windows.
Ia64\DevCon.exe 64-bit DevCon tool binary.

Note The source code for DevCon is also available in the Windows XP DDK (which is available from http://www.microsoft.com/ddk/) under DDK root\Src\Setup\Devcon, along with documentation.
Using DevCon
DevCon is a command-line utility with built-in documentation. If you run the devcon help command, the following list of commands and descriptions appears. The devcon help command will give more detailed help on any command. With some of these commands, you can specify a remote target computer. These commands work if you are using the 32-bit version of DevCon on WOW64. Device Console Help:
devcon.exe [-r] [-m:\\<machine>] <command> [<arg>...]
-r if specified will reboot machine after command is complete, if needed.
<machine> is name of target machine.
<command> is command to perform (see below).
<arg>... is one or more arguments if required by command.
For help on a specific command, type: devcon.exe help <command>
classfilter Allows modification of class filters.
classes List all device setup classes.
disable Disable devices that match the specific hardware or
instance ID.
driverfiles List driver files installed for devices.
drivernodes Lists all the driver nodes of devices.
enable Enable devices that match the specific hardware or
instance ID.
find Find devices that match the specific hardware or
instance ID.
findall Find devices including those that are not present.
help Display this information.
hwids Lists hardware ID's of devices.
install Manually install a device.
listclass List all devices for a setup class.
reboot Reboot local machine.
remove Remove devices that match the specific hardware or
instance ID.
rescan Scan for new hardware.
resources Lists hardware resources of devices.
restart Restart devices that match the specific hardware or
instance ID.
stack Lists expected driver stack of devices.
status List running status of devices.
update Manually update a device.
UpdateNI Manually update a device without user prompt
SetHwID Adds, deletes, and changes the order of hardware IDs of root-enumerated devices.

Example DevCon Commands
devcon -m:\\test find pci\*

Lists all known PCI devices on the computer test. (By using-m, you can specify a target computer. You must use Interprocess communication (IPC) to access the computer.)

devcon -r install Windows directory\Inf\Netloop.inf *MSLOOP

Installs a new instance of the Microsoft loopback adaptor. This creates a new root-enumerated device node with which you can install a "virtual device," such as the loopback adaptor. This command also restarts the computer silently if a restart is required.

devcon classes

Lists all known setup classes. The output contains the short nonlocalized name (for example, "USB") and the descriptive name (for example, "Universal Serial Bus controllers").

devcon classfilter upper !filter1 !filter2

Deletes the two specified filters.

devcon classfilter lower !badfilter +goodfilter

Replaces the "badfilter" with the "goodfilter".

devcon driverfiles =ports

Lists files that are associated with each device in the ports setup class.

devcon disable *MSLOOP

Disables all devices that have a hardware ID that ends in "MSLOOP" (including "*MSLOOP").

devcon drivernodes @ROOT\PCI_HAL\PNP0A03

Lists all compatible drivers for the device ROOT\PCI_HAL\PNP0A03. This can be used to determine why an integral device information (.inf) file was chosen, instead of a third-party .inf file.

devcon enable '*MSLOOP

Enables all devices that have a hardware ID of "*MSLOOP". The single quotation mark indicates that the hardware ID must be taken literally (in other words, the asterisk ["*"] actually is an asterisk; it is not a wildcard character).

devcon find *

Lists device instances of all devices that are present on the local computer.

devcon find pci\*

Lists all known peripheral component interconnect (PCI) devices that are on the local computer (this command assumes that a device is PCI if it has a hardware ID that is prefixed by "PCI\").

devcon find =ports *pnp*

Lists devices that are present that are a member of the ports setup class and that contain "PNP" in their hardware ID.

devcon find =ports @root\*

Lists devices that are present that are a member of the ports setup class and that are in the "root" branch of the enum tree (the instance ID is prefixed by "root\"). Note that you should not make any programmatic assumption about how an instance ID is formatted. To determine root devices, you can look at device status bits. This feature is included in DevCon to aid in debugging.

devcon findall =ports

Lists "nonpresent" devices and devices that are present for the ports class. This includes devices that have been removed, devices that have been moved from one slot to another, and, in some cases, devices that have been enumerated differently due to a BIOS change.

devcon listclass usb 1394

Lists all devices that are present for each class named (in this case, USB and 1394).

devcon remove @usb\*

Removes all USB devices. Devices that are removed are listed with their removal status.

devcon rescan

Rescans for new Plug and Play devices.

devcon resources =ports

Lists the resources that are used by all devices in the ports setup class.

devcon restart =net @'ROOT\*MSLOOP\0000

Restarts the loopback adaptor ROOT\*MSLOOP\0000. The single quotation mark in the command indicates that the instance ID must be taken literally.

devcon sethwid @ROOT\LEGACY_BEEP\0000 := beep

Assign the hardware ID, beep, to the legacy beep device.

devcon stack =ports

Lists the expected driver stack for the device. This includes device and class upper/lower filters, and the controlling service.

devcon status @pci\*

Lists the status of each device present that has an instance ID that begins with "pci\".

devcon status @ACPI\PNP0501\1

Lists the status of a specific device instance, in this case an Advanced Configuration and Power Interface (ACPI)-enumerated serial port.

devcon status @root\rdp_mou\0000

Lists the status of the Microsoft Terminal Server or Terminal Services mouse driver.

devcon status *PNP05*

Lists the status of all COM ports.

devcon update mydev.inf *pnp0501

Updates all devices that exactly match the hardware ID *pnp0501 to use the best driver in Mydev.inf that is associated with the hardware ID *pnp0501.

Note: This update forces all devices to use the driver in Mydev.inf, even if there is a better match already on the system. This is useful when you want to install new versions of drivers during development before you obtain a signature. The update affects only the devices that match the specified hardware ID, and does not affect the child devices. If the specified .inf file is unsigned, Windows may display a dialog box that prompts you to confirm whether the driver should be installed. If a restart is required, this is reported and DevCon returns a level 1 error. If you specify -r, this causes a restart to occur automatically if one is required.

NOTES
Devcon will return an error level for use in scripts:
"0" indicates a success.
"1" indicates that a restart is required.
"2" indicates a failure.
"3" indicates a syntax error.

If you specify -r and a restart is required, the restart occurs without warning after all devices have been processed.
If you specify -m:\\computer and the command will not work for a remote computer, an error is reported.
Devcon allows wildcards in instance IDs for interactive convenience. Do not assume anything about the format of an instance ID from computer to computer and from operating system version to operating system version.
Microsoft Knowledge Base Article - 311272

建議?
如果您對此文章有任何建議或意見,請在下面輸入(最多 255 個字)

General Information
聯繫我們
支持的選項和價格,電話和網上支持

客戶服務
客戶意見,產品購買,站點和產品信息


頁面選項
傳送
列印


文件:DevCon 指令行實用工具 - 裝置管理員的替換選項)
適用於
本文的發佈號曾為 CHS311272
概要
"DevCon"實用工具是一種指令行實用工具,可以替代裝置管理員。它允許您啟用、禁用、重新啟動、更新、刪除和查詢單個設備或一組設備。DevCon 提供對開發人員有用但無法在裝置管理員中直接獲得的信息。

DevCon 是為在 Windows 2000 和 Windows XP 上使用而設計的。它無法執行於 Microsoft Windows 95、Windows 98 或 Windows ME。
更多信息
DevCon 不可再分發。提供它是為了用作偵錯和開發工具。您可以隨意修改 DevCon 以供個人專用。此示例演示如何有效地配合使用 SetupAPI 和 CfgMgr32 API 來枚舉設備和執行設備操作。

下面的文件可從 Microsoft 下載中心下載:

DevCon.exe

發行日期:2001 年 11 月 1 日

有關如何下載 Microsoft 支持文件的其他信息,請按下以下文章編號,檢視 Microsoft 知識庫文章:
119591 How to Obtain Microsoft Support Files from Online Services(如何從連線電腦服務獲取 Microsoft 支持文件)

Microsoft 已掃瞄此文件沒有病毒。在發表當日 Microsoft 使用了最新的病毒檢測軟體以掃瞄此文件是否有病毒。此文件儲存在安全伺服器上,以防對它進行任何未經授權的更改。

DevCon.exe 文件包含以下文件:

文件 說明
I386\DevCon.exe 32 位 DevCon 工具二進制文件。在 64 位 Windows 上將不會完全發揮作用。
Ia64\DevCon.exe 64 位 DevCon 工具二進制文件。

備註:DevCon 的來源碼及相關我的文件也包括在 Windows XP DDK(可從 http://www.microsoft.com/ddk/ 下載)中,位於 DDK 根目錄 \Src\Setup\Devcon 下。
使用DevCon
DevCon 是具有內裝我的文件的指令行實用工具。如果您執行指令行 devcon help,則將顯示下面的指令及說明列表。指令 devcon help command 將提供有關任一指令的更詳細的說明 。其中的某些指令允許您指定遠端目標電腦。在 WOW64 上也可使用使用 DevCon 的 32 位版本。 Device Console Help:
devcon.exe [-r] [-m:\\<machine>] <command> [<arg>...]
-r if specified will reboot machine after command is complete, if needed.
<machine> is name of target machine.
<command> is command to perform (see below).
<arg>... is one or more arguments if required by command.
For help on a specific command, type:devcon.exe help <command>
classfilter Allows modification of class filters.
classes List all device setup classes.
disable Disable devices that match the specific hardware or
instance ID。
driverfiles List driver files installed for devices.
drivernodes Lists all the driver nodes of devices.
enable Enable devices that match the specific hardware or
instance ID。
find Find devices that match the specific hardware or
instance ID。
findall Find devices including those that are not present.
help Display this information.
hwids Lists hardware ID's of devices.
install Manually install a device.
listclass List all devices for a setup class.
reboot Reboot local machine.
remove Remove devices that match the specific hardware or
instance ID。
rescan Scan for new hardware.
resources Lists hardware resources of devices.
restart Restart devices that match the specific hardware or
instance ID。
stack Lists expected driver stack of devices.
status List running status of devices.
update Manually update a device.
DevCon 指令示例
devcon find *

列出本機電腦上所有設備的設備實例。

devcon find pci\*

列出本機電腦上所有已知的外圍元件互連 (PCI) 設備(此指令假定:如果設備具有以"PCI\"開頭的硬體 ID,則該設備是 PCI 設備)

devcon -m :\\test find pci\*

列出電腦"test"上的所有 PCI 設備。(您可以使用 -m 來指定目標電腦。需要對電腦進行工作間通信 (IPC) 訪問的許可。)

devcon classes

列出所有已知的安裝類。輸出中包含未本機化的簡稱(例如,"USB")和描述性名稱(例如,"Universal Serial Bus controllers")。

devcon listclass usb 1394

為指定的每個類(在本例中為 USB 和 1394)列出所有存在的設備。

devcon find =ports *pnp*

列出是 ports 安裝類的成員且其硬體 ID 包含"PNP"的已存在設備。

devcon find =ports @root\*

列出是 ports 安裝類的成員且位於 enum 樹的"root"分支中的已存在設備(實例 ID 以"root\"開頭)。請注意,有關實例 ID 的格式化方式,不應作任何編程假定。若要確定根設備,可以檢查裝置狀態位。為了說明 進行偵錯,DevCon 中包括了此功能。

devcon findall =ports

列出 ports 類的"不存在"設備以及已存在設備。這將包括已經移除的設備、已經從一個插槽移動到另一插槽的設備以及(在某些情況下)由於 BIOS 更改而以不同方式枚舉的設備。

devcon status @pci\*

列出其實例 ID 以"pci\"開頭的已存在設備的狀態。

devcon status @ACPI\PNP0501\1-

列出特定設備實例的狀態,在本例中為進階配置與電源接頭 (ACPI) 枚舉的串行連接埠。

devcon status @root\rdp_mou\0000

列出 Microsoft 終端伺服器或終端服務滑鼠驅動程式的狀態。

devcon status *PNP05*

列出所有 COM 連接埠的狀態。

devcon resources =ports

列出 ports 安裝類中的所有設備所使用的資源。

devcon driverfiles =ports

列出與 ports 安裝類中的每個設備關聯的文件。

devcon stack =ports

列出設備的期望驅動程式堆棧。這包括設備和類的高層/低層篩選器以及控制服務。

devcon drivernodes @ROOT\PCI_HAL\PNP0A03

列出設備"ROOT\PCI_HAL\PNP0A03"的所有相容驅動程式。這可用於確定選項選項某一 INF 文件而不是第三方 INF 的原因。

devcon remove @usb\*

移除所有 USB 設備。將列出已移除的設備及其移除狀態。

devcon rescan

重新掃瞄以搜尋新的即插即用設備。

devcon update mydev.inf *pnp0501

更新與硬體 ID"*pnp0501"完全匹配的所有設備,以便使用 Mydev.inf 中與硬體 ID *pnp0501 關聯的最佳驅動程式。請注意,即使系統上已經存在更好的匹配項,這也將強制所有設備使用 Mydev.inf 中的驅動程式。如果在獲得簽名之前,您想要在開發程序中安裝驅動程式的新版本,則這是很有用的。它僅影響與指定的硬體 ID 匹配的設備,而不影響子設備。如果指定的 .inf 文件未經簽名,則 Windows 可能會顯示一個對話視窗,提示您驗證是否應安裝驅動程式。如果需要重新啟動,則會提示您這樣做,而且 DevCon 將返回錯誤級別"1"。如果指定了"-r",則將導致自動重新啟動(如果需要重新啟動)。

devcon -r install Windows directory \Inf\Netloop.inf *MSLOOP

安裝 Microsoft 環回橋接器的新實例。這將新增新的根枚舉的設備節點,以允許您安裝"虛擬設備"(如環回橋接器)。此指令還以無提示方式重新啟動電腦(如果需要重新啟動)。

devcon disable *MSLOOP

禁用其硬體 ID 以"MSLOOP"(包括"*MSLOOP")結尾的所有設備。

devcon enable '*MSLOOP

啟用其硬體 ID 為"*MSLOOP"的所有設備。單引號指示必須按字面解釋硬體 ID(換句話說,星號 ["*"] 實際上只是 一個星號;它不是萬用字元)。

devcon restart =net @'ROOT\*MSLOOP\0000

重新啟動環回橋接器"ROOT\*MSLOOP\0000"。單引號指示必須按字面解釋實例 ID。

Devcon classfilter upper !filter1 !filter2

刪除兩個指定的篩選器。

Devcon classfilter lower !badfilter +goodfilter

將"badfilter"替換為"goodfilter"。

備註
Devcon 將返回在指令碼中使用的錯誤級別:
"0"指示成功。
"1"指示需要重新啟動。
"2"指示失敗。
"3"指示語法錯誤。

如果指定了 -r 而且需要重新啟動,則在處理完所有設備後會進行重新啟動,而且不發出警告。
如果指定了-m :\\ computer 但此指令對於遠端電腦不起作用,則會報告一個錯誤。
Devcon 允許在實例 ID 中使用萬用字元,以便於進行交互。不要根據一台電腦或一種操作系統版本去推測另一台電腦或另一種操作系統版本的實例 ID 格式。
這篇文章中的信息適用於:
Microsoft Windows 2000 驅動程式開發工具包 (DDK)
Microsoft Windows XP 驅動程式開發工具包 (DDK)
最近更新: 2003-1-13 (1.1)
關鍵字 kbDDK kbDSupport kbfile kbGrpDSNTDDK kbhowto KB311272

Microsoft和/或其各供應商對於為任何目的而在本伺服器上發佈的文件及有關圖形所含信息的適用性,不作任何宣告。 所有該等文件及有關圖形均"依樣"提供,而不帶任何性質的保證。Microsoft和/或其各供應商特此宣告,對所有與該等信息有關的保證和條件不負任何責任,該等保證和條件包括關於適銷性、符合特定用途、所有權和非侵權的所有默示保證和條件。在任何情況下,在由於使用或執行本伺服器上的信息所引起的或與該等使用或執行有關的訴訟中,Microsoft和/或其各供應商就因喪失使用、資料或利潤所導致的任何特別的、間接的或衍生性的損失或任何種類的損失,均不負任何責任,無論該等訴訟是合同之訴、疏忽或其它侵權行為之訴。

ian78 2003-10-25 05:45 AM

感謝分亨 :)


所有時間均為台北時間。現在的時間是 09:12 PM

Powered by vBulletin® 版本 3.6.8
版權所有 ©2000 - 2020, Jelsoft Enterprises Ltd.

『服務條款』

* 有問題不知道該怎麼解決嗎?請聯絡本站的系統管理員 *


SEO by vBSEO 3.6.1