PowerShell禁用并启用驱动程序 [英] PowerShell disable and enable a driver

查看:273
本文介绍了PowerShell禁用并启用驱动程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有时重新启动/冷启动后,Win8中的触摸屏驱动程序出现问题,所以现在必须手动重新启动它。

Sometimes after restart/coldboot I got a problem with my touchscreen driver in Win8, so I've to restart it manually by now.

所以我想写登录后启动的脚本,它将禁用驱动程序并再次启用它。

So I want to write a script that starts after login, which will disable the driver and enables it again.

我实际上发现是找到了驱动程序,并且我可以获取驱动程序的对象列表。驱动程序通过:

I actually found out to find the driver and that I can get a object list of the drivers via:

Get-WmiObject Win32_PnPSignedDriver| select devicename, driverversion | where {$_.devicename -like "I2C*"}

但添加 |禁用设备到该行的末尾将不起作用。

But adding "| Disable-Device" to the end of the line will not work.

有人可以告诉我如何正确编写命令吗?并像批处理文件一样启动脚本?

Can anyone tell me how I have to write the command correctly and start the script like an batch file?

推荐答案

至少在Windows 10中要容易得多:

at least with Windows 10 it is a lot easier:

$d = Get-PnpDevice| where {$_.friendlyname -like "I2Cwhatever*"}
$d  | Disable-PnpDevice -Confirm:$false
$d  | Enable-PnpDevice -Confirm:$false

这篇关于PowerShell禁用并启用驱动程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆