WMI(CIM)が楽かな。
powershellでもVBScriptでもwmicでもお好きなもので。
PowerShell版:
$enabledCd = 0
$disabledCd = 22
$methodName = $null
$device = Get-CimInstance -Query 'select * from Win32_PnpEntity where Name = "Fax"'
if ($device.Status -eq 'OK' -and $device.ConfigManagerErrorCode -eq $enabledCd) {
$methodName = 'Disable'
}
elseif ($device.Status -eq 'Error' -and $device.ConfigManagerErrorCode -eq $disabledCd) {
$methodName = 'Enable'
}
if (! [string]::IsNullOrEmpty($methodName)) {
$result = Invoke-CimMethod -InputObject $device -MethodName $methodName
$result
}
ワンライナー版:
powershell -c "$d=gcim -cl Win32_PnpEntity -f 'Name=''Fax'''; $s,$c=$d.Status,$d.ConfigManagerErrorCode; if($n=if($s -eq 'OK' -and $c -eq 0){'Disable'}elseif($s -eq 'Error' -and $c -eq 22){'Enable'}){$d|icim -m $n}"
【.cmd】 バッチファイルスクリプト %15 【.bat】
■ このスレッドは過去ログ倉庫に格納されています
409デフォルトの名無しさん
2023/07/24(月) 23:51:25.15ID:wZUfbAlM■ このスレッドは過去ログ倉庫に格納されています
ニュース
- 「ほぼ全人類が永久に失業する」Anthropic研究者がAIの未来を予測★4 [♪♪♪★]
- 【台湾不支持へ】トランプ米大統領、米中首脳会談で「台湾独立を支持しない」と発言… ★3 [BFU★]
- 高市総理 トランプ大統領との電話会談を調整 [煮卵★]
- 高市首相 訪中出迎えのタラップに「40cm超」異常な段差 左手で機体の一部を掴みながら、なんとか右足を下ろす★2 [♪♪♪★]
- 【旭川】ゲームセンターなどで大暴れ 3歳と5歳含む男女9人に暴行しけがさせる 女を逮捕 10/30にも同ゲーセンで現行犯逮捕 [七波羅探題★]
- 女優の美村里江 現場で感じた日本の貧困「お弁当が小さくなっている」「プロデューサーが身銭を」スタッフ差し入れに感謝も… [muffin★]