@echo off
REM  Copyright (c) Corbett Research Pty Ltd
REM  1/14 Hilly St, Mortlake NSW 2137 Australia
REM  +61 2 9736 1320
REM
REM NOTICE:  This program is protected by copyright laws, trade mark and
REM international copyright treaties, as well as other intellectual property
REM laws and treaties. This SOFTWARE product is licensed, not sold.
REM
REM Unauthorized reproduction or distribution of this program, or any portion of
REM it, may result in severe civil and criminal penalties, and violators will be
REM prosecuted to the maximum extent possible under law.
REM

setlocal

cls
echo Copyright (c) Corbett Research Pty Ltd
echo.
echo This script forces the software to use the usb drivers deployed by this 
echo software version. This script should not be used unless your are having 
echo issues connecting to the RG6000.
echo.
echo Press Ctrl-C at any time to exit.

set firsttime=1

ver | find "Windows 98">NUL
if not errorlevel 1 goto invalidOS
ver | find "Windows Millennium" > nul
if not errorlevel 1 goto invalidOS
ver | find "Windows NT" > nul
if not errorlevel 1 goto invalidOS

:scanusb
REM Make sure error message about device not connected does not show the first time.

if %firsttime%==0 echo.
if %firsttime%==0 echo ERR:RG6000 does not appear to be connected.
set firsttime=0

usbtool find "USB\Vid_c0b8&Pid_e007" | find /i "USB\Vid_c0b8&Pid_e007" > nul
if errorlevel 1 goto notconnected
goto connected

:notconnected
echo.
echo *******************************************************
echo *                                                     *
echo * Please connect your RG6000 unit using the USB cable *
echo *                                                     *
echo *******************************************************

pause
goto scanusb

goto end

:connected
echo.
echo Forcing drivers to update ...
usbtool update .\rgbus.inf "USB\Vid_c0b8&Pid_e007" | find /i "failed" > nul
if errorlevel 1 echo Driver updated successfully.
goto end

:invalidOS
echo.
echo This script does not support Windows 98, Windows NT, Windows Millenium.
:end