From 03c24ef14e429b7c147bfa33431c1f7363999c13 Mon Sep 17 00:00:00 2001 From: kytv <kytv@mail.i2p> Date: Sat, 17 Sep 2011 22:15:45 +0000 Subject: [PATCH] query the status of the service before doing anything --- .../resources/install_i2p_service_winnt.bat | 22 ++++++++++++------- .../resources/uninstall_i2p_service_winnt.bat | 10 +++++++++ 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/installer/resources/install_i2p_service_winnt.bat b/installer/resources/install_i2p_service_winnt.bat index 04d7c16ce9..14d6c2261d 100644 --- a/installer/resources/install_i2p_service_winnt.bat +++ b/installer/resources/install_i2p_service_winnt.bat @@ -83,6 +83,20 @@ if not [%_WRAPPER_CONF%]==[""] ( ) set _WRAPPER_CONF="%_WRAPPER_CONF_DEFAULT%" +:: Query status of service. +:: We remove an existing service to +:: 1) force the service to stop (this will stop the "can't upgrade +:: because file is in use" forum posts from people re-running the +:: installer to get the new version. +:: 2) update service configuration in case wrapper.config was edited +:: 3) prevent hanging the installer if 'install as service' is selected +:: and it's already enabled as a service. +"%_WRAPPER_EXE%" -qs %_WRAPPER_CONF% + if not %errorlevel%==0 ( + "%_WRAPPER_EXE%" -r %_WRAPPER_CONF% + call "%~dp0set_config_dir_for_nt_service.bat" uninstall +) + :: Add service path to wrapper.config call "%_REALPATH%"\set_config_dir_for_nt_service.bat install @@ -97,20 +111,12 @@ set _PARAMETERS=%_PARAMETERS% %1 shift if not [%1]==[] goto :parameters -:: We remove the existing service to -:: 1) force the service to stop -:: 2) update service configuration in case wrapper.config was edited -:: 3) prevent hanging the installer if 'install as service' is selected -:: and it's already enabled as a service. if [%_PASS_THROUGH%]==[] ( - "%_WRAPPER_EXE%" -r %_WRAPPER_CONF% "%_WRAPPER_EXE%" -i %_WRAPPER_CONF% ) else ( - "%_WRAPPER_EXE%" -r %_WRAPPER_CONF% -- %_PARAMETERS% "%_WRAPPER_EXE%" -i %_WRAPPER_CONF% -- %_PARAMETERS% ) if not errorlevel 1 goto :eof -if "%2"=="--nopause" goto :eof pause :eof diff --git a/installer/resources/uninstall_i2p_service_winnt.bat b/installer/resources/uninstall_i2p_service_winnt.bat index 63277d495b..c72eacbed9 100644 --- a/installer/resources/uninstall_i2p_service_winnt.bat +++ b/installer/resources/uninstall_i2p_service_winnt.bat @@ -82,6 +82,16 @@ if not [%_WRAPPER_CONF%]==[""] ( ) set _WRAPPER_CONF="%_WRAPPER_CONF_DEFAULT%" +:: check status of the service. If %errorlevel% is 0 +:: the service is not installed. If the service +:: isn't installed there isn't anything for us to do +:: other than exit. +"%_WRAPPER_EXE%" -qs %_WRAPPER_CONF% +if %errorlevel%==0 ( + echo The I2P Service service was not installed. + goto eof +) + call "%_REALPATH%"\set_config_dir_for_nt_service.bat uninstall rem rem Uninstall the Wrapper as an NT service. -- GitLab