@echo off
REM using DPInst for doing the job
REM setting to console mode but not quiet mode because Win7 does not allow unsigned drivers
setlocal ENABLEDELAYEDEXPANSION

:next
pnputil /e > driverlist.txt

set "driverProvider=Prolific"

set "removepackPubliser="
set "removepackProvider="
set "removepackVersion="
::enumerate through all driver list to find correct driver
for /f "usebackq tokens=1,2 delims=:" %%a in (driverlist.txt) do (
	if "%%a"=="Published name " (
	set removepackPubliser=%%b 
    set removepackPubliser=!removepackPubliser: =!
	set /a c=1
	)
	if "%%a"=="Driver package provider " (
	set removepackProvider=%%b 
    set removepackProvider=!removepackProvider: =!
	set /a c=2
	)
	if "%%a"=="Driver date and version " (
	set removepackVersion=%%b 
    set removepackVersion=!removepackVersion: =!
	set /a c=3
	)
	if "%%a"=="Signer name " (
	set /a c=4
	)
	if !c!==4 (
		if !removepackProvider!==!driverProvider! (			
			if "%ProgramFiles(x86)%" == "" goto X32

			:X64
			cd dpinst\MultiLin\amd64\

			goto next1
			:X32
			cd dpinst\MultiLin\x86\

			goto next1
			:next1
			dpinst.exe /q /u c:/windows/inf/!removepackPubliser!
			cd ..\..\..
			set /a c=0
			goto next
		)
		
	)
)
del driverlist.txt

if "%ProgramFiles(x86)%" == "" goto X32

:X641

cd dpinst\MultiLin\amd64\

rem quiet install
dpinst.exe /q /lm /PATH ..\..\..\Driver\

rem non-quiet install -> need when driver is not whql
rem dpinst.exe /lm /PATH ..\..\..\Driver\

cd ..\..\..
goto END


:X321

cd dpinst\MultiLin\x86\

rem quiet install
dpinst.exe /q /lm /PATH ..\..\..\Driver\

rem non-quiet install -> need when driver is not whql
rem dpinst.exe /lm /PATH ..\..\..\Driver\

cd ..\..\..
goto END


:END