Script - Save current Drivers to C:\

Discussion in 'Scripting' started by MJAINC, Nov 23, 2023.

  1. MJAINC

    MJAINC MDL Novice

    Nov 16, 2018
    22
    14
    0
    #1 MJAINC, Nov 23, 2023
    Last edited: Nov 25, 2023
    Hello I wrote a script to save all current files to C drive
    in a folder called DRIVERS

    for backup or import ...into new installation.
    figured it would be handy for someone who installs winders alot like me.
    " ExportDrivers.ps1" save as and run with PS.

    Code:
    
    if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) { Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs; exit }
    mkdir C:\Drivers
    
    DISM.exe /Online /Export-Driver /Destination:C:\Drivers
    
    
    
     
  2. iam5or10

    iam5or10 MDL Novice

    Nov 6, 2022
    2
    0
    0
    Similar to my ghetto compiled one au3

    Code:
    ;;Win10 Dirver Backup
    #include <MsgBoxConstants.au3>
    #include <AutoItConstants.au3>
    
    #RequireAdmin
    
    Sleep(200)
    Run(@SystemDir & "\system32\WindowsPowerShell\v1.0\powershell.exe")
    ConsoleWrite(@SystemDir & "\system32\WindowsPowerShell\v1.0\powershell.exe" & @CRLF)
    Sleep(200)
    WinWait("Powershell")
    WinActivate("Powershell")
    Send("Set-ExecutionPolicy -ExecutionPolicy Unrestricted")
    Sleep(200)
    Send("{ENTER}")
    Sleep(3000)
    Send("a")
    Sleep(200)
    Send("{ENTER}")
    SplashTextOn("Wait", "Waiting for finish")
    Sleep(5000)
    SplashOff()
    $dPath = DirCreate(@WorkingDir & "\DriverBackup")
    Send("Export-WindowsDriver -Online -Destination " & $dPath)
    Sleep(200)
    Send("{ENTER}")
     
  3. atplsx

    atplsx MDL Addicted

    May 11, 2009
    606
    1,851
    30
    I think pnputil is the best method, not using dism.
    No need to mess, exports all drives
    pnputil /export-driver * C:\Drivers
    Re install commands
    Cd C:\Drivers
    pnputil /add-driver *.inf /install /subdirs