Advertisement
FreeBooter

Backup_drivers

Aug 20th, 2022
1,251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 1.77 KB | Fixit | 0 0
  1. :: Backup and Restore Device Drivers in Windows 10 and Windows 11
  2.  
  3. @Echo Off & cls
  4.    
  5. (Net session >nul 2>&1)||(PowerShell start """%~0""" -verb RunAs & Exit /B)
  6.    
  7. Setlocal EnableDelayedExpansion
  8.    
  9. :choice
  10.  
  11. Cls & Mode CON  LINES=11 COLS=40 & Color 0E & Title Created By FreeBooter
  12. Echo.
  13. Echo.
  14. Echo.
  15. Echo        Export Drivers  (E)?  
  16. Echo.      
  17. Echo        Import Drivers  (I)?
  18. Echo.
  19.  
  20.  
  21. Set /p input= RESPONSE:
  22.  
  23. If /i  Not %input%==E (Goto :_Ex) Else (Goto :_Backup)
  24.  
  25. :_Ex
  26. If /i Not %input%==I  (Goto :choice) Else (Goto :_Restore)
  27.  
  28.  
  29.  
  30. :_Backup
  31.     mode con cols=95 lines=5 & color 0E
  32.     Call :BrowseForFolder "Please choose the source folder for to backup drivers" SourceFolder
  33.     If defined SourceFolder (
  34.         echo(
  35.         echo             You chose "!SourceFolder!" as source folder
  36.     ) else (
  37.         echo(
  38.         Color 0C & echo                    The source folder is not defined ... Exiting ......
  39.         Timeout /T 2 /nobreak>nul & exit
  40.     )
  41.  
  42. Dism /online /export-driver /destination:"!SourceFolder!"
  43.  
  44. Timeout /T 4 /nobreak>nul & exit
  45.  
  46.    
  47.  
  48.  
  49. :_Restore  
  50.     mode con cols=95 lines=5 & color 0E
  51.    
  52.     Call :BrowseForFolder "Please choose the target folder for to restore drivers" TargetFolder
  53.     If defined TargetFolder (
  54.         echo(
  55.         echo             You chose "!TargetFolder!" as Target folder
  56.     ) else (
  57.         echo(
  58.         Color 0C & echo                    The Target folder is not defined ... Exiting ......
  59.         Timeout /T 2 /nobreak>nul & exit
  60.     )
  61. Timeout /T 3 /nobreak>nul
  62.     (
  63. pnputil /add-driver "!TargetFolder!\*.inf" /subdirs /install /reboot
  64.     )
  65. Timeout /T 6 /nobreak>nul & exit
  66.    
  67.    
  68.    
  69.     :BrowseForFolder
  70. set "psCommand="(new-object -COM 'Shell.Application')^
  71. .BrowseForFolder(0,'%1',0,0).self.path""
  72. for /f "usebackq delims=" %%I in (`powershell %psCommand%`) do set "%2=%%I"
  73. exit /b
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement