0% found this document useful (0 votes)
65 views3 pages

Driver Installation Script Overview

This script is designed to install drivers for a specified module on a Windows system, logging the process to a file. It checks the environment (online or offline) and verifies hardware IDs before proceeding with the installation. The script utilizes tools like DISM and pnputil for driver management and logs all actions and results for troubleshooting purposes.

Uploaded by

devkotasushil096
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
65 views3 pages

Driver Installation Script Overview

This script is designed to install drivers for a specified module on a Windows system, logging the process to a file. It checks the environment (online or offline) and verifies hardware IDs before proceeding with the installation. The script utilizes tools like DISM and pnputil for driver management and logs all actions and results for troubleshooting purposes.

Uploaded by

devkotasushil096
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

@echo off

REM Created by MVP v2.0.9.9


REM Please replace DriverProvider, DriverCategory, DriverItemType variables with
exact names
SET DriverModule=Intel Intel VGA UMA
title Installing %DriverModule%
SET OSDST=%~d0
if not exist %~d0\OEM\Preload\Command\POP*.ini set OSDST=C:
if not exist %OSDST%\OEM\AcerLogs md %OSDST%\OEM\AcerLogs
SET LogPath=%OSDST%\OEM\AcerLogs\[Link]
ECHO.>>%LogPath%
ECHO Installing, please wait...
SETLOCAL ENABLEDELAYEDEXPANSION
pushd "%~dp0"

ECHO %DATE% %TIME%[Log START] ============ %~dpnx0 ============ >> %LogPath%

SET OSEnv=Online
ECHO %DATE% %TIME%[Log TRACE] reg query "HKEY_LOCAL_MACHINE\Software\Microsoft\
Windows NT\CurrentVersion\WinPE" >>%LogPath% 2>&1
reg query "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\WinPE"
>>%LogPath% 2>&1
ECHO.>>%LogPath%
if !errorlevel! equ 0 (
ECHO !DATE! !TIME![Log TRACE] Running in the WinPE, SET OSEnv=Offline >>
%LogPath%
SET OSEnv=Offline
ECHO !DATE! !TIME![Log TRACE] call :CheckingHWID for Offline >>%LogPath%
2>&1
call :CheckingHWID >>%LogPath% 2>&1
ECHO !DATE! !TIME![Log TRACE] Getting return code is !ExitCode! >>%LogPath%
2>&1
if !ExitCode! neq 9 (
ECHO !DATE! !TIME![Log TRACE] Driver HWID not matched with Device.
goto :END >>%LogPath% 2>&1
goto :END
) else ( ECHO !DATE! !TIME![Log TRACE] Driver HWID is matched with Device,
contiune. >>%LogPath% 2>&1 )
) else if /i "%SystemDrive%" neq "%OSDST%" (
ECHO !DATE! !TIME![Log TRACE] Running in the Offline, SET OSEnv=Offline >>
%LogPath%
SET OSEnv=Offline
ECHO !DATE! !TIME![Log TRACE] call :CheckingHWID for Offline >>%LogPath%
2>&1
call :CheckingHWID >>%LogPath% 2>&1
ECHO !DATE! !TIME![Log TRACE] Getting return code is !ExitCode! >>%LogPath%
2>&1
if !ExitCode! neq 9 (
ECHO !DATE! !TIME![Log TRACE] Driver HWID not matched with Device.
goto :END >>%LogPath% 2>&1
goto :END
) else ( ECHO !DATE! !TIME![Log TRACE] Driver HWID is matched with Device,
contiune. >>%LogPath% 2>&1 )
) else (
ECHO !DATE! !TIME![Log TRACE] This is Online installation. >>%LogPath% 2>&1
)
if exist %OSDST%\OEM\Preload\Command\POP*.ini ECHO [%DriverModule%]>> %OSDST%\OEM\
Preload\[Link]
for /f "tokens=*" %%v in ([Link]) do (
if /i "%OSEnv%" equ "Offline" (
ECHO !DATE! !TIME![Log TRACE] DISM /image:%OSDST%\ /add-driver
/driver:"%%v" >> %LogPath%
DISM /image:%OSDST%\ /add-driver /driver:"%%v" >> %LogPath% 2>&1
) else (
ECHO !DATE! !TIME![Log TRACE] pnputil /add-driver "%%v" /install >>
%LogPath%
pnputil /add-driver "%%v" /install >> %LogPath% 2>&1
ECHO !DATE! !TIME![Log TRACE] pnputil -i -a "%%v" >> %LogPath%
pnputil -i -a "%%v" >> %LogPath% 2>&1
)
ECHO.>>%LogPath%

for /f "skip=1 tokens=2 delims=,;" %%s in ('find /i "DriverVer" "%%v"') do (


if exist %OSDST%\OEM\Preload\Command\POP*.ini ECHO %%~nxv=%%s>> %OSDST%\
OEM\Preload\[Link]
)
)
if exist %OSDST%\OEM\Preload\Command\POP*.ini ECHO.>> %OSDST%\OEM\Preload\
[Link]

:END
ECHO %DATE% %TIME%[Log Leave] ============ %~dpnx0 ============ >> %LogPath%
ECHO.>>%LogPath%

popd
SETLOCAL DISABLEDELAYEDEXPANSION
ECHO Install finished
exit /b 0

:CheckingHWID
for /f "delims=" %%D in ('powershell get-date -format "{yyyyMMddHHmmss}"') do SET
CurrentDateTime=%%D
ECHO %DATE% %TIME%[Log TRACE] dir /b *.enc
for /f "tokens=1 delims=." %%F in ('dir /b *.enc') do set DRVDir=!CurrentDateTime!_
%%F

ECHO %DATE% %TIME%[Log TRACE] pnputil /enum-devices /deviceids


pnputil /enum-devices /deviceids >Pnputil_deviceids_WinPE.txt
if %errorlevel% neq 0 (
ECHO %DATE% %TIME%[Log TRACE] pnputil /enum-devices /deviceids return
[%errorlevel%], using pnputil /enum-devices /ids
pnputil /enum-devices /ids >Pnputil_deviceids_WinPE.txt
)

ECHO %DATE% %TIME%[Log TRACE] copy /y Pnputil_deviceids_WinPE.txt C:\OEM\Acerlogs\


Pnputil_deviceids_WinPE_%DRVDir%.txt
copy /y Pnputil_deviceids_WinPE.txt C:\OEM\Acerlogs\Pnputil_deviceids_WinPE_%DRVDir
%.txt

ECHO %DATE% %TIME%[Log TRACE] [Link] -noprofile -executionpolicy


unrestricted -command ".\CheckMatchedHWID.ps1; exit $LASTEXITCODE"
[Link] -noprofile -executionpolicy unrestricted -command ".\
CheckMatchedHWID.ps1; exit $LASTEXITCODE"
SET ExitCode=!errorlevel!
exit /b %ExitCode%

You might also like