@echo off REM ################################################################## REM # Setup Service REM # Vers. 0.0.1 25.01.2009 Mark Wolfgruber REM ################################################################## echo. echo %date% %time% ### Start Setup ### echo. :vars set __prgname__=JFritz set __prgpath__=%ProgramFiles%\JFritz set __prg__=JFritz.exe set __servicepath__=%__prgpath__%\service set __srvany__=%__servicepath__%\srvany.exe set __instsrv__=%__servicepath__%\instsrv.exe set __stopsrv__=%__servicepath__%\stop-service_%__prgname__%.bat set __startsrv__=%__servicepath__%\start-service_%__prgname__%.bat set __restartsrv__=%__servicepath__%\restart-service_%__prgname__%.bat set __installsrv__=%__servicepath__%\install-service_%__prgname__%.bat set __removesrv__=%__servicepath__%\remove-service_%__prgname__%.bat set __regfile__=%__servicepath__%\registry_service_%__prgname__%.reg set "__regprgpath__=%__prgpath__:\=\\%" :check_path if not exist %__servicepath__% md %__servicepath__% if not exist %__servicepath__% echo ERROR, can not create %__servicepath__% && PAUSE && EXIT :check_srvany if not exist %__srvany__% ( if exist srvany.exe ( echo copy srvany.exe %__srvany__% copy srvany.exe %__srvany__% ) ELSE ( echo. echo Download srvany.exe from Microsoft Recource Kit and echo copy it to %__srvany__% ) ) if not exist %__srvany__% echo ERROR, can not create %__srvany__% && PAUSE && EXIT :check_instsrv if not exist %__instsrv__% ( if exist instsrv.exe ( echo copy instsrv.exe %__instsrv__% copy instsrv.exe %__instsrv__% ) ELSE ( echo. echo Download instsrv.exe from Microsoft Recource Kit and echo copy it to %__instsrv__% ) ) if not exist %__instsrv__% echo ERROR, can not create %__instsrv__% && PAUSE && EXIT :update_setup set __setupfile__=setup-Service-%__prgname__%.cmd xcopy /Y /V /D /R %__setupfile__% %__servicepath__%\. > nul :create_regfile echo Windows Registry Editor Version 5.00 > %__regfile__% echo. >> %__regfile__% echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\%__prgname__%\Parameters] >> %__regfile__% echo "Application"="%__regprgpath__%\\%__prg__%" >> %__regfile__% echo "AppDirectory"="%__regprgpath__%\\" >> %__regfile__% if not exist %__regfile__% echo ERROR, can not create %__regfile__% && PAUSE && EXIT :register_regfile regedit /s %__regfile__% :setup_service echo. echo Please start the Application with an spezial/own Account echo. if "%__service_accountname__%"=="" set __service_accountname__=%USERDOMAIN%\%USERNAME% SET /P __service_accountname__=Domain\Accountname for Service [%__service_accountname__%]: :delete_old_batches if exist %__servicepath__%\*%__prgname__%.bat del %__servicepath__%\*%__prgname__%.bat :create_batches echo @net stop %__prgname__% > %__stopsrv__% echo @pause >> %__stopsrv__% echo @net start %__prgname__% > %__startsrv__% echo @pause >> %__startsrv__% echo @net stop %__prgname__% > %__restartsrv__% echo @net start %__prgname__% >> %__restartsrv__% echo @pause >> %__restartsrv__% echo @echo off > %__installsrv__% echo @%__instsrv__% %__prgname__% REMOVE ^> nul > %__removesrv__% echo set __service_accountname__=%__service_accountname__% >> %__installsrv__% echo SET /P __service_accountname__=Domain\Accountname for Service [%%__service_accountname__%%]: >> %__installsrv__% echo SET /P __PW__=Password: >> %__installsrv__% echo %__instsrv__% %__prgname__% %__srvany__% -a %%__service_accountname__%% -p %%__PW__%% >> %__installsrv__% echo pause >> %__installsrv__% echo @%__instsrv__% %__prgname__% REMOVE > %__removesrv__% echo @pause >> %__removesrv__% :install_srv set __a__=N set /p __a__=Install Service %__prgname__% now? [%__a__%] if "%__a__%"=="j" set __a__=Y if "%__a__%"=="J" set __a__=Y if "%__a__%"=="y" set __a__=Y if "%__a__%"=="Y" ( call %__installsrv__% ) ELSE ( goto end ) :start_srv set __a__=N set /p __a__=Start the Service %__prgname__% now? [%__a__%] if "%__a__%"=="j" set __a__=Y if "%__a__%"=="J" set __a__=Y if "%__a__%"=="y" set __a__=Y if "%__a__%"=="Y" call %__startsrv__% :end start "Explorer" C:\WINDOWS\explorer.exe /n, /e, %__servicepath__% echo. echo %date% %time% ### END of Setup ### echo. echo Setup is now finished, please use the Batch files to echo start, stop, restart, install or remove the Service %__prgname__% echo. dir /s /b %__servicepath__%\*%__prgname__%.bat echo. pause