LaDEEKill3R

Backup or Restore Device Drivers Re-Upload by IT Groceries Co.,Ltd

Oct 30th, 2021 (edited)
1,397
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 2.42 KB | None | 0 0
  1. :: This script was created by Matthew Wai at TenForums.com/members/matthew-wai.html
  2. :: http://www.tenforums.com/tutorials/68426-backup-restore-device-drivers-windows-10-a.html
  3. :: ************************************************************************************/
  4. @echo off & Title Backup or Restore Device Drivers by IT Groceries Co.,Ltd. %date% %time% & mode con Lines=8 cols=93 & color 17
  5. (Net session >nul 2>&1)&&(cd /d "%~dp0")||(PowerShell start """%~0""" -verb RunAs & Exit /B)
  6. :: ************************************************************************************/
  7. echo.
  8. echo    Press (1) to back up all 3rd-party device drivers into a folder.
  9. echo    Press (2) to restore all 3rd-party device drivers from a folder.
  10. echo    Press (3) to restore a device driver backup via Device Manager.
  11. :Choice
  12. CHOICE /C "123" /M "Your choice?:" >nul 2>&1  
  13. If %errorlevel%==1  (goto Option_1) & Exit
  14. If %errorlevel%==2  (goto Option_2) & Exit
  15. If %errorlevel%==3  (goto Option_3) & Exit
  16. Exit
  17. :Option_1
  18. Call:✶ "Please select a folder or click on [ Make New Folder ] at the bottom. It is advisable to select a folder on an external device." SourceFolder
  19. :
  20. Set "✱="(new-object -COM 'Shell.Application').BrowseForFolder(0,'%1',0,0).self.path""
  21. For /f "usebackq delims=" %%# in (`PowerShell %%`) do set "【Folder】=%%#"
  22. If "%【Folder】%"=="" (Goto Choice & Exit)
  23. dism /online /export-driver /destination:"%【Folder】%"
  24. Echo.&Echo    The device drivers have been exported into the following folder:
  25. Echo    "%【Folder】%" & Echo.&Echo    Press a key to exit.
  26. pause >nul & Exit
  27. Exit
  28. :Option_2
  29. Call:✶ "Please select the folder containing the device drivers previously exported." SourceFolder
  30. :
  31. Set "✱="(new-object -COM 'Shell.Application').BrowseForFolder(0,'%1',0x200,0).self.path""
  32. For /f "usebackq delims=" %%# in (`PowerShell %%`) do set "【Folder】=%%#"
  33. If "%【Folder】%"=="" (Goto Choice & Exit)
  34. Echo.
  35. Echo    If necessary, the computer will be automatically restarted to complete the operation of
  36. Echo    importing the drivers. Please save and close anything open and then press a key to start
  37. Echo    the operation.
  38. Echo.
  39. pause >nul
  40. pnputil /add-driver "%【Folder】%\*.inf" /subdirs /install /reboot
  41. echo. & Echo    The process has completed successfully.
  42. Echo    If the computer does not automatically reboot, you may press a key to exit.
  43. pause >nul & Exit
  44. Exit
  45. :Option_3
  46. Start "" "devmgmt.msc" & Exit
Add Comment
Please, Sign In to add comment