You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过Windows CMD筛选佳能、富士通USB扫描仪的状态信息

提取指定品牌USB扫描仪的设备描述与状态

方法1:PowerShell脚本(精准高效)

cmd的字符串处理能力有限,推荐用PowerShell实现,支持远程执行:

# 替换为目标远程电脑的主机名/IP
Invoke-Command -ComputerName "远程设备名称" -ScriptBlock {
    # 筛选佳能、富士通的USB扫描仪
    Get-PnpDevice | Where-Object {
        ($_.FriendlyName -match "CANON|FUJITSU") -and 
        ($_.InstanceId -match "USB") -and 
        ($_.Class -eq "ImageScanner")
    } | Select-Object FriendlyName, Status
} | Format-Table -AutoSize

本地执行则去掉远程连接部分:

Get-PnpDevice | Where-Object {
    ($_.FriendlyName -match "CANON|FUJITSU") -and 
    ($_.InstanceId -match "USB") -and 
    ($_.Class -eq "ImageScanner")
} | Select-Object FriendlyName, Status

方法2:纯cmd批处理脚本

如果必须用cmd环境,创建ScanDeviceStatus.bat文件,内容如下:

@echo off
setlocal enabledelayedexpansion

set "tempfile=%temp%\devicelist.tmp"
pnputil /enum-devices > "%tempfile%"

set "currentName="
for /f "tokens=* delims=" %%a in (%tempfile%) do (
    echo "%%a" | findstr /i "CANON FUJITSU" >nul
    if not errorlevel 1 (
        set "currentName=%%a"
        set "currentName=!currentName:*Device description: =!"
    )
    if defined currentName (
        echo "%%a" | findstr /i "Status:" >nul
        if not errorlevel 1 (
            set "currentStatus=%%a"
            set "currentStatus=!currentStatus:*Status: =!"
            echo 设备名称: !currentName!
            echo 设备状态: !currentStatus!
            echo ------------------------
            set "currentName="
        )
    )
)

del "%tempfile%"
endlocal

双击执行批处理,即可输出目标设备的名称与对应状态。

补充说明

  • PowerShell方法能精准定位扫描仪类设备,避免误匹配其他同品牌USB设备
  • cmd批处理通过临时文件和延迟变量扩展,实现设备描述与状态行的配对提取

内容的提问来源于stack exchange,提问作者Hakan DAŞTAN

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.10 16:52:12