how to get the DeviceID only from this ouput by using wmic command

  • 8 months ago
Comment

ChatGPT
1 / 1

It seems like you're trying to extract the DeviceID value from the output of a wmic command. To achieve this, you can use a combination of wmic and find commands to filter the output and extract the desired value. Here's an example:

Let's assume you have a command that outputs information like this:

makefile
Caption=Network Connection
DeviceID=Local Area Connection
...

And you want to extract the DeviceID value. You can use the following command:

batch
@echo off

for /f "tokens=2 delims==" %%G in ('wmic YourWmiClass where "YourCondition" get DeviceID /value ^| find "DeviceID"') do (
set "deviceID=%%G"
)

echo Device ID: %deviceID%

Replace YourWmiClass with the appropriate WMI class and YourCondition with the condition that matches the specific instance you're interested in. This script uses a combination of wmic and find to filter and extract the DeviceID value.

Please adjust the script according to your specific use case.