简体   繁体   English

参数错误从PowerShell,但不是从cmd

[英]parameter wrong from powershell but not from cmd

From a command shell (cmd.exe) Win10 the following call is correct: 从命令外壳程序(cmd.exe)Win10,以下调用正确:

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

But if I do the same from powershell I get the result 但是如果我从powershell进行同样的操作,我会得到结果

No matching devices found.

The same with that: 与此相同:

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

If I look at the string with the following all seems correct. 如果我看下面的字符串,那一切似乎都是正确的。

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

use start-Process instead: 使用start-Process代替:

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

WindowStyle and wait are of course optionnal WindowStyle和wait当然是可选的

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM