简体   繁体   中英

Can't deploy application as windows service from shortcut in Windows Server 2008 r2

I'm have a java application. Thi application run as windows service (with procrun wrapper) on Windows Server 2008 r2. Application install as windows service via install.bat file with this text:

set "APPLICATION_SERVICE_HOME=%cd%"

set SERVICE_NAME=CollectDO 
set PR_DESCRIPTION= Обеспечивает прием сведений по ДО и запись их в БД
set PR_DISPLAYNAME=Сбор данных по ДО 
set EXECUTABLE_NAME=prunsrv.exe
set PR_INSTALL=%APPLICATION_SERVICE_HOME%\%EXECUTABLE_NAME% 

REM Service log configuration set
PR_LOGPREFIX=%SERVICE_NAME%
set PR_LOGPATH=%APPLICATION_SERVICE_HOME%\Servicelog
set PR_LOGLEVEL=Info
REM Path to java installation
set PR_JVM=..\..\jre\bin\server\jvm.dll
set PR_CLASSPATH=..\dist\SvhWinService.jar
REM Startup configuration
set PR_STARTUP=auto
set PR_STARTMODE=jvm
set PR_STARTCLASS=svhwinservice.SvhWinServWrapper
set PR_STARTMETHOD=start
REM Shutdown configuration
set PR_STOPMODE=jvm
set PR_STOPCLASS=%PR_STARTCLASS%
set PR_STOPMETHOD=stop
REM JVM configuration
set PR_JVMMS=256
set PR_JVMMX=1024
set PR_JVMSS=4000
set PR_JVMOPTIONS=-Duser.language=EN;-Duser.region=en

:remove
::---- Remove the service -------
 %EXECUTABLE_NAME% //DS//%SERVICE_NAME%
 echo The service '%SERVICE_NAME%' has been removed
REM goto end

REM Install service
%EXECUTABLE_NAME% //IS//%SERVICE_NAME%

When I'm start this file from console (cmd.exe) as administrator - then service deploy normal. But if i'm create shortcut to install.bat and try start as administratot - then service not deploy. I'm think that this is because user control account (because on Windows XS and Windows Server 2003 deploy from shortcut work fine), but I can not change these settings. How resoved this trouble on Windows server 2008 r2?

The truble was resolved. Need add this row to header of bat file

cd /d %~dp0

With out this row the current dir returned by %cd% is windows\\system32, instead bat dir.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM