I have encountered the Error 1603/1602 while installing the HCKInstall\Client\Setup.exe on several machines. It appears to be generic at first, but it's not. The error code is being passed from the Service back to the MSI. It means that a service failed
to start. The key is that it happens at the very end of the installation and then does the rollback. The solution is to figure out which service failed and then remove it and the directories.
Here is what I did.
I created batch to kick off before I install the client now. It basically checks for installed HCK products and if there uninstalls them. Then checks for the state of each service and if running stops the service before attempting to remove the HCK/WLK leftovers.
Then it removes the sticky directory.
@ECHO OFF
:: Defaults...
:: Default:_HCK_Services_="DTMService,FtsSvc,WLKSvc,WTTNotification,WTTResultsRelayAgent" services.
SET _HCK_Services_=
:: Default:_Directories_="C:^\Program Files ^(x86^)^\Microsoft Driver Test Manager"
SET _Directories_=
:: Default:_DEBUG_=off, use debug_on to change
SET _DEBUG_=
:: Examples: Comma delimited lists param1=Services param2=directory param3=debug_on
:: ^<command.bat^> "DTMService,FtsSvc","C^:^\Program Files ^(x86^)^\Microsoft Driver Test Manager",c^:^\test, "debug_on"
::SetVars:
SET _HCK_Services_=%1
IF /I "%2" NEQ "" SET _Directories_=%2
:: SetDefaults:
IF /I "%3" GEQ "debug_on" SET _DEBUG_=True
IF NOT DEFINED _HCK_Services_ (
SET _HCK_Services_=DTMService,FtsSvc,WLKSvc,WTTNotification,WTTResultsRelayAgent
)
IF NOT DEFINED _Directories_ SET _Directories_=C:\Program Files (x86)\Microsoft Driver Test Manager
:: Clear Parans on directories
set _Directories_=%_Directories_:(x86)=replace_x86%
:: CallMainFunctions:
CALL:UninstallHCK
CALL:CheckVersion
CALL:Main "%_HCK_Services_%"
:Main
FOR %%A IN (%~1) DO (
REM Checking for Active Services ant attempting
IF DEFINED _DEBUG_ (
ECHO Checking %%A...
)
FOR /F "tokens=3 delims=: " %%H IN ('sc query "%%A" ^| findstr "STATE"') DO (
IF DEFINED _DEBUG_ (
ECHO Service:"%%A" Status:"%%H"
)
IF /I "%%H" NEQ "" (
IF DEFINED _DEBUG_ (
ECHO Service "%%A" is installed but not %%H.
)
) ELSE IF /I "%%H" GEQ "RUNNING" (
IF DEFINED _DEBUG_ (
ECHO. %%A %%H
ECHO Attempting to Stop %%A
)
SC STOP "%%A" >NUL
) ELSE IF /I "%%H" GEQ "START_PENDING" (
IF DEFINED _DEBUG_ (
ECHO. %%A %%H
)
REM Need to wait for it to fail before we can stop the service.
IF DEFINED _DEBUG_ (
ECHO Attempting to Stop %%A in 60 seconds...
)
PING.EXE 1.1.1.1 -n 1 -w 60000 >NUL
SC STOP "%%A" >NUL
) ELSE (
CALL:print Service, "%%A", Error, "Unexpected Results"
)
)
FOR /F "tokens=3 delims=: " %%H IN ('sc query "%%A" ^| findstr "STATE"') DO (
IF /I "%%H" NEQ "STOPPED" (
CALL:print Service, %%A, Failure_To_STOP, %%H
) ELSE (
CALL:print Service, %%A, State, %%H
CALL:delete_Service %%A
)
)
FOR /F "tokens=* delims=: " %%H IN ('sc query "%%A" ^| findstr "FAILED"') DO (
IF DEFINED _DEBUG_ (
ECHO Service:"%%A" is not installed.
ECHO. State:%%H
)
CALL:print Service, %%A, FinalState, "Not Installed"
)
)
CALL:RemoveDirectories "%_Directories_%"
GOTO:EOF
:UninstallHCK
CALL:CheckInstallation "{3BEE5E5E-8BEE-F691-4349-7B2B41FF3A59}", UninstallString
IF DEFINED _REGKEYFOUND_ MsiExec.exe /X{3BEE5E5E-8BEE-F691-4349-7B2B41FF3A59} /qb+
CALL:CheckInstallation "{6F8333B4-7DB1-E6D3-52ED-5641F8F38B76}", UninstallString
IF DEFINED _REGKEYFOUND_ MsiExec.exe /X{6F8333B4-7DB1-E6D3-52ED-5641F8F38B76} /qb+
CALL:CheckInstallation "{A329307E-3CCD-57BF-47EF-1B857D1AF08E}", UninstallString
IF DEFINED _REGKEYFOUND_ MsiExec.exe /X{A329307E-3CCD-57BF-47EF-1B857D1AF08E} /qb+
CALL:CheckInstallation "{F1213F53-D794-2021-E14E-F4BEED1BBF3B}", UninstallString
IF DEFINED _REGKEYFOUND_ MsiExec.exe /X{F1213F53-D794-2021-E14E-F4BEED1BBF3B} /qb+
GOTO:EOF
:RemoveDirectories
SET _RemoveDirectories_1_=%~1
SET _RemoveDirectories_1_=%_RemoveDirectories_1_:"=%
SET _RemoveDirectories_1_=%_RemoveDirectories_1_:'=%
FOR /f "tokens=1-8 delims=," %%A IN ("%_RemoveDirectories_1_%") DO (
IF "%%A" GEQ ":" (
CALL:RMDIR "%%A"
)
IF "%%B" GEQ ":" (
CALL:RMDIR "%%B"
)
IF "%%C" GEQ ":" (
CALL:RMDIR "%%C"
)
IF "%%D" GEQ ":" (
CALL:RMDIR "%%D"
)
IF "%%E" GEQ ":" (
CALL:RMDIR "%%F"
)
IF "%%G" GEQ ":" (
CALL:RMDIR "%%H"
)
IF "%%I" GEQ ":" (
CALL:RMDIR "%%I"
)
IF "%%J" GEQ ":" (
CALL:RMDIR "%%J"
)
)
exit /b 0
FOR %%A IN ('%_RemoveDirectories_1_%') DO (
ECHO.Dir=%%A
REM CALL:RMDIR '%%A'
)
GOTO:EOF
:RMDIR
:: GET Parans back
SET _THEDIR_=%~1
SET _DirStatus_=
set _THEDIR_=%_THEDIR_:replace_x86=(x86)%
set _THEDIR_=%_THEDIR_:"=%
set _THEDIR_=%_THEDIR_:'=%
IF NOT EXIST "%_THEDIR_%" goto endof
RMDIR "%_THEDIR_%" /S /Q
IF NOT EXIST "%_THEDIR_%" (
SET _DirStatus_=Removed
) ELSE (
SET _DirStatus_=Failed To Remove Directory
)
CALL:print RemoveDirectory, "%_THEDIR_%", Results, "%_DirStatus_%"
:endof
GOTO:EOF
:print
SET var_3=%~3
IF DEFINED var_3 (
ECHO ^{^[^'%~1^'^]='%~2', ^[^'%~3^'^]='%~4'^}
) ELSE (
ECHO ^{^[^'%~1^'^]='%~2'^}
)
GOTO:EOF
:delete_Service
sc.exe delete "%~1" >Nul
IF %ERRORLEVEL% NEQ 0 (
CALL:print Service, %~1, FinalState, "Failed To Uninstall"
) ELSE (
CALL:print Service, %~1, Current_State, Uninstalled
)
GOTO:EOF
:TestStr
SET _ORIGINAL_=%~2
SET STR2=%~2
SET STR3=%~3
SET STR4=%~4
REM ECHO.Str2="!STR2!"
SET STR2=!STR2:%~1=!
REM echo.STR2="!STR2!"
IF /I NOT "!STR2!" EQU "!_ORIGINAL_!" (
SET %STR3%=%STR4%
)
GOTO:EOF
:CheckVersion
REM Check Windows Version and sets variable for _Version_ and _OSType_
REM Enhancement will be to install dependencies required for HCK
SET _VERSION_=
SET _OSType_=
SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
FOR /F "usebackq delims=" %%i IN (`VER`) DO (
SET _VERSION_=%%i
SET _VERSION_=!_VERSION_:[=!
SET _VERSION_=!_VERSION_:]=!
REM CALL:TestStr "6.1", "!_VERSION_!", _OSType_, Windows_7_2008R2
CALL:TestStr "5.0", "!_VERSION_!", _OSType_, Windows_2000
CALL:TestStr "5.1", "!_VERSION_!", _OSType_, Windows_XP
CALL:TestStr "5.2", "!_VERSION_!", _OSType_, Windows_2003
CALL:TestStr "6.0", "!_VERSION_!", _OSType_, Windows_Vista_2008R1
CALL:TestStr "6.1", "!_VERSION_!", _OSType_, Windows_7_2008R2
CALL:TestStr "6.2", "!_VERSION_!", _OSType_, Windows_2012
)
CALL:print OSType, !_OSType_!
CALL:print !_Version_!
ENDLOCAL && SET _OSType_=%_OSType_% && SET _VERSION_=%_VERSION_%
GOTO:EOF
:CheckInstallation
SET _REGKEYFOUND_=
SET KEY_NAME="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\%~1"
SET VALUE_NAME=%~2
FOR /F "usebackq skip=4 tokens=1-3" %%A IN (`REG QUERY %KEY_NAME% /v %VALUE_NAME% 2^>nul`) DO (
SET ValueName=%%A
SET ValueType=%%B
SET ValueValue=%%C
)
IF DEFINED ValueName (
SET _REGKEYFOUND_=True
CALL:print "REGKEY", "%~2", Name, "%ValueName%"
CALL:print "REGKEY", "%~2", Value_Type, "%ValueType%"
CALL:print "REGKEY", "%~2", Value_Value, "%ValueValue%"
) else (
CALL:print "REGKEY", "%~2", "%KEY_NAME%\%VALUE_NAME%", "not found."
)
GOTO:EOF
:Done
-
Edited by
Gary Lee Baird Jr
Saturday, March 30, 2013 12:49 AM
-
Proposed as answer by
Gary Lee Baird Jr
Saturday, March 30, 2013 12:50 AM