diff --git a/installer/resources/install_i2p_service_winnt.bat b/installer/resources/install_i2p_service_winnt.bat index 04d7c16ce9ac8d206755a7eaa995f8fd41041b8c..14d6c2261dfcc9445aa6b9bce83616b29ef0632c 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 63277d495b00e67dc5664f8eb89d04cd081def18..c72eacbed934530107b2eceadf1253bb428033f0 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.