簡體   English   中英

參數錯誤從PowerShell,但不是從cmd

[英]parameter wrong from powershell but not from cmd

從命令外殼程序(cmd.exe)Win10,以下調用正確:

.\devcon.exe disable "USB\VID_0547&PID_1002&REV_0000"

但是如果我從powershell進行同樣的操作,我會得到結果

No matching devices found.

與此相同:

$retDevice = Get-WmiObject Win32_PNPEntity | select PnpDeviceID | where {$_.pnpdeviceid -like "USB\VID_0547&*"}
$callparam = $(" disable"  +" " + $retDevice.pnpdeviceid.ToString()) + """"
.\devcon.exe  $callparam

如果我看下面的字符串,那一切似乎都是正確的。

$callparam | Out-Default
out -> disable USB\VID_0547&PID_1002\5&22AA7556&0&2"

使用start-Process代替:

Start-Process -FilePath $PathToDevcon -ArgumentList @('enable', '"USB\VID_0547&PID_1002&REV_0000"') -WindowStyle Hidden -Wait 

WindowStyle和wait當然是可選的

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM