Replace WMIC-based check for ViGEmBus with a Powershell check
This version is simpler and much faster on machines with many installed apps.
This commit is contained in:
@@ -2,28 +2,17 @@
|
|||||||
setlocal enabledelayedexpansion
|
setlocal enabledelayedexpansion
|
||||||
|
|
||||||
rem Check if a compatible version of ViGEmBus is already installed (1.17 or later)
|
rem Check if a compatible version of ViGEmBus is already installed (1.17 or later)
|
||||||
set Version=
|
rem
|
||||||
for /f "usebackq delims=" %%a in (`wmic product where "name='ViGEm Bus Driver' or name='Nefarius Virtual Gamepad Emulation Bus Driver'" get Version /format:Textvaluelist`) do (
|
rem Note: We use exit code 2 to indicate success because either 0 or 1 may be returned
|
||||||
for /f "delims=" %%# in ("%%a") do set "%%#"
|
rem based on the PowerShell version if an exception occurs.
|
||||||
)
|
powershell -c Exit $(if ((Get-Item "$env:SystemRoot\System32\drivers\ViGEmBus.sys").VersionInfo.FileVersion -ge [System.Version]"1.17") { 2 } Else { 1 })
|
||||||
|
if %ERRORLEVEL% EQU 2 (
|
||||||
rem Extract Major and Minor versions
|
goto skip
|
||||||
for /f "tokens=1,2 delims=." %%a in ("%Version%") do (
|
|
||||||
set "MajorVersion=%%a"
|
|
||||||
set "MinorVersion=%%b"
|
|
||||||
)
|
|
||||||
|
|
||||||
rem Compare the version to 1.17
|
|
||||||
if /i !MajorVersion! gtr 1 goto skip
|
|
||||||
if /i !MajorVersion! equ 1 (
|
|
||||||
if /i !MinorVersion! geq 17 (
|
|
||||||
goto skip
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
goto continue
|
goto continue
|
||||||
|
|
||||||
:skip
|
:skip
|
||||||
echo "The installed version is %Version%, no update needed. Exiting."
|
echo "The installed version is 1.17 or later, no update needed. Exiting."
|
||||||
exit /b 0
|
exit /b 0
|
||||||
|
|
||||||
:continue
|
:continue
|
||||||
|
|||||||
Reference in New Issue
Block a user