@echo off 
set SOFT_NAME=HPVisionTerm
set COMP_NAME=Hewlett-Packard
set VERSION=1.4.02.00
set DISPVER=1.4.02.00


@echo off

@ECHO\
@ECHO 正在卸载，请稍候……
@ECHO\

set INSDIR=
set PROFILE_PATH=

set "INS_REG_KEY=HKLM\Software\%COMP_NAME%\%SOFT_NAME%"
set "UNINS_REG_KEY=HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall\%SOFT_NAME%"

@rem *************************************************************************************
@rem				Get install path
@rem *************************************************************************************

reg query "%INS_REG_KEY%"

if not errorlevel 0 (
@echo 没有发现安装程序的路径。
goto EndUninstall
)

for /f "tokens=2*" %%i in ('reg query "%INS_REG_KEY%" /v Path') do set "INSDIR=%%j"
for /f "tokens=2*" %%i in ('reg query "%INS_REG_KEY%" /v ProfilePath') do set "PROFILE_PATH=%%j"

@rem *************************************************************************************
@rem				delete desktop shortcut link
@rem *************************************************************************************

@ECHO\
@echo 正在删除桌面快捷方式...
@ECHO\
@ECHO\

Set "ShortcutRemover=%INSDIR%\RemoveShortcuts.vbs"
@If Exist "%ShortcutRemover%" (cscript "%ShortcutRemover%" "wt.exe" "hpvt.exe")

@rem *************************************************************************************
@rem				delete files
@rem *************************************************************************************

@if NOT Exist "%PROFILE_PATH%\sessions\*.conf" goto SAVECONFIG

set choice=
set /p "choice=是否保留创建的连接配置文件(Y/n)？"
if not "%choice%"=="" set "choice=%choice:~0,1%"
if /i NOT "%choice%"=="n" goto SAVECONFIG

rd "%PROFILE_PATH%" /s /q
@reg delete "%INS_REG_KEY%" /f
cd ..

:SAVECONFIG

echo on

@reg delete "%UNINS_REG_KEY%" /f
@rd "%INSDIR%\conf" /s /q
@rd "%INSDIR%\i386" /s /q
@del "%INSDIR%\*.*" /q /A-R

:EndUninstall

@ECHO\
@ECHO\
@echo 卸载结束
@ECHO\
@ECHO\

@echo on
::Delete the uninstall script itself.
@del "%INSDIR%\Uninstall.bat" /q /F

:: This script file has been be removed and nothing could be executed after this line.


