@echo off x:\loginw.exe -f x:\Admin.pwl -c SITESERVER -d DOMAIN -t 30 if not exist Z:\ net use Z: \\SITESERVER\drivers set LOGDIR=X:\ set LOGFL="%LOGDIR%%COMPUTERNAME%.DriverMgmt_Script.log" echo %date% %time% Beginning Driver Script > %LOGFL% REM :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: REM Determine Computer Model REM :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: for /f "tokens=*" %%A IN ('wmic path win32_computersystem get model /Value ^| FIND "="') DO ( SET CS.%%A ) echo %date% %time% The Computer Model is %CS.Model% >> %LOGFL% REM :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: REM Determine Destination Drive REM :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: for /f "tokens=*" %%A IN ('wmic Path Win32_LogicalDisk Where "MediaType='12'" Get Name /Value ^| FIND "="') DO ( SET LD.%%A call:CheckFile ) echo %date% %time% The Selected Windows Drive is %DRIVE% >> %LOGFL% REM :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: REM Check for and Set Source Driver Directory REM :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: set SOURCE="Z:\x64\%CS.Model%" if not exist %SOURCE% ( Echo %date% %time% Driver Source %SOURCE% does not exist. >> %LOGFL% Exit 0 ) else ( echo %date% %time% The Driver Source is %SOURCE% >> %LOGFL% ) set DEST="%DRIVE%\Drivers\%CS.Model%" echo %date% %time% The Driver Destination is %DEST% >> %LOGFL% REM :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: REM Set RoboCopy options and copy drivers REM :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: set RBOPTS=/E /R:2 /W:15 /LOG:"%LOGDIR%%COMPUTERNAME%.robocopy.log" echo %date% %time% Starting Driver Copy using RoboCopy >> %LOGFL% type %LOGFL% START /WAIT ROBOCOPY %SOURCE% %DEST% %RBOPTS% echo %date% %time% RoboCopy Return Code: %ERRORLEVEL% >> %LOGFL% REM :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: REM Set Dism Options and inject drivers REM :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: set DISMOPTS=/image:%DRIVE%\ /scratchdir:"%DRIVE%\Windows\Temp" /Add-Driver /driver:"%DRIVE%\Drivers" /ForceUnsigned set DISMOPTS=%DISMOPTS% /recurse /quiet /norestart /logpath:"%LOGDIR%%COMPUTERNAME%.dism_drivers.log" echo %date% %time% Starting Driver Injection using Dism >> %LOGFL% cls type %LOGFL% "X:\Windows\system32\dism.exe" %DISMOPTS% echo Dism Command: "X:\Windows\system32\dism.exe" %DISMOPTS% >> %LOGFL% echo %date% %time% Dism Return Code: %ERRORLEVEL% >> %LOGFL% cls echo :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: type %LOGFL% echo :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: rem type "%LOGDIR%%COMPUTERNAME%.robocopy.log" rem echo :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: rem type "%LOGDIR%%COMPUTERNAME%.dism_drivers.log" rem pause Exit 0 :CheckFile if exist %LD.Name%\Windows\Tasks Set DRIVE=%LD.Name% Echo %date% %time% DRIVE variable set to %DRIVE% >> %LOGFL% goto:eof