@ECHO OFF
:: ======================================================================
:: File:        REMOVE.BAT
:: 
:: Contains:    Virtual PC Network Services for Windows NT 4.0
::              uninstallation batch file.
:: 
:: Copyright:   (c) 2001-2003, Connectix Corporation
:: ======================================================================

:: Save the current directory
PUSHD

:: This batch script is for installation under Windows NT 4.0 only
VER | FIND /I "Windows NT Version 4.0">NUL
IF ERRORLEVEL 1 GOTO Fatal_WrongWindowsVersion

:: Enable command extensions - See HELP SETLOCAL for information on the
:: following idiom.
VERIFY OTHER 2>NUL
SETLOCAL ENABLEEXTENSIONS
IF ERRORLEVEL 1 GOTO :Fatal_UnableToEnableExtensions

:: Setup some common constants
SET Manufacturer=Connectix
SET Option=VPCNetNT
SET ProductKey=Software\%MANUFACTURER%\%OPTION%\CurrentVersion

:: The source directory may be specified in the first batch parameter.
:: If the source directory is not specified, assume the source directory
:: is the current directory.
IF NOT [%1]==[] CD /D %1
FOR /F "delims=" %%A IN ('CD') DO SET CurDir=%%A

:: Find the name of the INF file for the current installation.
IF EXIST %TEMP%\%Option%.TMP DEL %TEMP%\%Option%.TMP
START /W REGEDIT /E %TEMP%\%Option%.TMP HKEY_LOCAL_MACHINE\%ProductKey%\NetRules
IF NOT EXIST %TEMP%\%Option%.TMP GOTO Fatal_SoftwareNotInstalled

FOR /F "tokens=2 delims==" %%G IN ('TYPE %TEMP%\%Option%.TMP ^| FIND "InfName"') DO SET OemFilename=%%G
DEL %TEMP%\%Option%.TMP
IF "%OemFilename%"=="" GOTO :Fatal_SoftwareNotInstalled

:: Invoke setup to uninstall the driver
SETUP /f /i "%SystemRoot%\system32\ncpashel.inf" /T NTN_InstallMode = Deinstall /T NTN_Origination = NCPA /T NTN_Infname = %OemFilename% /T NTN_InfOption = %Option% /T NTN_RegBase = %ProductKey%
IF ERRORLEVEL 1 GOTO :Fatal_UnableToUninstall

:: Invoke setup to update the driver bindings
SETUP /f /i "%SystemRoot%\system32\ncpashel.inf" /T NTN_InstallMode = Install /T NTN_Origination = NCPA /T NTN_Infname = "%CurDir%\REBIND.INF"

ECHO ** NOTE: You must restart your computer in order for changes to take effect.

GOTO End

:Fatal_UnableToUninstall
ECHO ERROR: Software removal failed!
GOTO End

:Fatal_SoftwareNotInstalled
ECHO ERROR: Software not installed!
GOTO End

:Fatal_UnableToEnableExtensions
ECHO ERROR: Unable to enable command extensions.
GOTO End

:Fatal_WrongWindowsVersion
ECHO ERROR: This batch file may only be executed under Windows NT 4.0.

:End
ENDLOCAL

:: Restore the current directory
POPD


