Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/276.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/161.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用C+;在不重新启动的情况下禁用/启用USB驱动程序+/Windows 7中的C#/PowerShell_C#_C++_Powershell_Usb_Gpo - Fatal编程技术网

使用C+;在不重新启动的情况下禁用/启用USB驱动程序+/Windows 7中的C#/PowerShell

使用C+;在不重新启动的情况下禁用/启用USB驱动程序+/Windows 7中的C#/PowerShell,c#,c++,powershell,usb,gpo,C#,C++,Powershell,Usb,Gpo,我需要一种简单的方法,通过c++/c#/powershell脚本追溯禁用/启用Windows 7中的所有USB设备,而无需重新启动机器 我知道更改GPO是一种选择,但我似乎找不到任何不重新启动就能实现这一点的实现 请详细解释您的解决方案,我不熟悉Windows上的管理。使用PowerShell,您可以按如下操作 打开注册表并导航到以下注册表项,如果注册表项设置为“3”意味着电脑上已启用USB驱动器,则查看注册表项start的值 Get-ItemProperty "HKLM:\SYSTEM\Cu

我需要一种简单的方法,通过c++/c#/powershell脚本追溯禁用/启用Windows 7中的所有USB设备,而无需重新启动机器

我知道更改GPO是一种选择,但我似乎找不到任何不重新启动就能实现这一点的实现


请详细解释您的解决方案,我不熟悉Windows上的管理。

使用PowerShell,您可以按如下操作

打开注册表并导航到以下注册表项,如果注册表项设置为“3”意味着电脑上已启用USB驱动器,则查看注册表项start的值

Get-ItemProperty  "HKLM:\SYSTEM\CurrentControlSet\services\USBSTOR" -name start


PSPath       : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\USBSTOR
PSParentPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services
PSChildName  : USBSTOR
PSDrive      : HKLM
PSProvider   : Microsoft.PowerShell.Core\Registry
Start        : 3
如果要禁用它,可以使用下面的命令将值设置为4

Set-ItemProperty  "HKLM:\SYSTEM\CurrentControlSet\services\USBSTOR" -name start -Value 4
如果我再次检查注册表项的值,我会看到它已被修改为4,如果我插入USB驱动器,它将不会被检测到

Get-ItemProperty  "HKLM:\SYSTEM\CurrentControlSet\services\USBSTOR" -name start


PSPath       : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\USBSTOR
PSParentPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services
PSChildName  : USBSTOR
PSDrive      : HKLM
PSProvider   : Microsoft.PowerShell.Core\Registry
Start        : 4

使用PowerShell,您可以按如下操作

打开注册表并导航到以下注册表项,如果注册表项设置为“3”意味着电脑上已启用USB驱动器,则查看注册表项start的值

Get-ItemProperty  "HKLM:\SYSTEM\CurrentControlSet\services\USBSTOR" -name start


PSPath       : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\USBSTOR
PSParentPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services
PSChildName  : USBSTOR
PSDrive      : HKLM
PSProvider   : Microsoft.PowerShell.Core\Registry
Start        : 3
如果要禁用它,可以使用下面的命令将值设置为4

Set-ItemProperty  "HKLM:\SYSTEM\CurrentControlSet\services\USBSTOR" -name start -Value 4
如果我再次检查注册表项的值,我会看到它已被修改为4,如果我插入USB驱动器,它将不会被检测到

Get-ItemProperty  "HKLM:\SYSTEM\CurrentControlSet\services\USBSTOR" -name start


PSPath       : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\USBSTOR
PSParentPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services
PSChildName  : USBSTOR
PSDrive      : HKLM
PSProvider   : Microsoft.PowerShell.Core\Registry
Start        : 4

我很确定您在这里所做的改变了处理USB的服务的启动行为。然而,无论它是否已经运行,这都不会产生任何影响。我很确定问题的目标是一次性启用/禁用它们(例如,像一个全局开/关开关)。您好,您是否尝试在连接usb驱动器时运行此脚本?我很确定您在这里所做的是更改处理usb的服务的启动行为。然而,无论它是否已经运行,这都不会产生任何影响。我很确定问题的目标是一次性启用/禁用它们(例如,像一个全局开/关开关)。您好,您是否尝试在连接usb驱动器时运行此脚本??