windowsbatch-filecmdwmicwin32-process

How to find video adapter name with if-else statment use *.bat file


Can not figure out what is wrong, please help.

Main goal is look like this (pseudocode):

if(getCurrentVideoAdapterName().contains("List of video adapter names"))
{
print True
}else
{
print false
}

But this need to be done in *.bat file, I am a new in this and this is my trys:

SETLOCAL ENABLEDELAYEDEXPANSION
SET count=1
FOR /F "usebackq tokens=* skip=1" %%F IN (`wmic PATH Win32_videocontroller GET description`) DO (
  SET var!count!=%%F
  SET /a count=!count!+1
)
ECHO %var1%
ECHO %var2%
Findstr /c:%var1% listNameVideoAdapters.txt 
ENDLOCAL
if %errorlevel%==0 (
echo "True")
if %errorlevel%==1 (
echo "Falsee!")
pause

wmic PATH Win32_videocontroller GET description -return returns:

Description
NVIDIA GeForce GT 720M
Intel(R) HD Graphics 4000

and listNameVideoAdapters.txt contains a list with different video card names (include my NVIDIA GeForce GT 720M )


Solution

  • no need for a for loop:

    wmic PATH Win32_videocontroller GET description |findstr /g:listNameVideoAdapters.txt >nul && echo True || echo False
    

    findstr /g gets the list of strings to search from a file (which you already have)