[英]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.