title: Batch Script to run a computer test
body: <p>I am not really a programmer. I am a newbie.</p>
  
  <p>Can you guys please help me with a windows batch file that will run a computer test?</p>
  
  <ul>
  <li>Detect any hard drives then run a chkdisk on them</li>
  <li>Detect any usb port</li>
  <li>Detect any flash drive plug in the pc</li>
  <li>Check the display pixels</li>
  </ul>
  
  <p>I have started with this to detect the USB but somehow getting some errors</p>
  
  <pre>
  @echo off
  
  setlocal EnableDelayedExpansion
  set PNPDeviceID=4002FDCCE0E4D094
  set Q='wmic diskdrive where "interfacetype='USB' and PNPDeviceID like '%%%PNPDeviceID%%%'" assoc /assocclass:Win32_DiskDriveToDiskPartition'
  echo %Q%
  for /f "tokens=2,3,4,5 delims=,= " %%a in (%Q%) do (
    set hd=%%a %%b, %%c %%d
    call :_LIST_LETTER !hd!)
  goto :_END
  
  :_LIST_LETTER
  (echo %1 |find  "Disk ") >nul|| goto :_EOF 
  for /f "tokens=3 delims==" %%a in ('WMIC Path Win32_LogicalDiskToPartition  ^|find %1') do set TMP_letter=%%a
  set Part_letter=%TMP_letter:~1,2% 
  echo %Part_letter% %1
  goto :_EOF
  
  
  :_END
  :_EOF
  :: *** end
  pause
  </pre>