One-click restart device driver under Win10

Aug 01, 2021 18:37


1) create three batch files: enable, disable, and reboot (i call them myenable, mydisable, and myreboot to avoid ambiguity - pick meaningful names! e.g. disable_wifi rather than mydisable).

Store these somewhere in your PATH, to avoid having to do weird powershell string escaping.

1a) mydisable.bat
    pnputil /enable-device "instance_id"
(the instance_id is something like PCI\[gibberish] - you can look this up in Device Manager)

1b) myenable.bat
   pnputil /enable-device "instance_id"
(should be same instance_id)

1c) myreboot.bat
   powershell -Command "Start-Process powershell \"-ExecutionPolicy Bypass -NoProfile -Command `\"mydisable.bat\" -Verb RunAs"
   timeout /t 10
   powershell -Command "Start-Process powershell \"-ExecutionPolicy Bypass -NoProfile -Command `\"myenable.bat\" -Verb RunAs"

(this runs the commands with elevated privileges)

if running as a non-administrative user, also do the following (note: this is a potential security hole, so don't do this on work machines)

2) create a shortcut to myreboot.bat

3) in Properties, replace
   "c:\mypath\myreboot.bat"
with
   runas /user:myAdminUser /savecred "c:\mypath\myreboot.bat"

replace myAdminUser with a username which has administrative privileges (usually Administrator)

4) run it once, entering the admin's password when prompted. If asked to allow myreboot.bat to change the system, say yes.

5) done! this should save the credentials, and next time you just need to double-click the shortcut to reset your device.

Previous post
Up