参考:http://middleware123.com/weblogic/docs100/server_start/winservice.html http://docs.oracle.com/cd/E15523_01/web.1111/e13708/winservice.htm#i1188090 http://docs.oracle.com/cd/E15523_01/web.1111/e13708/winservice.htm 本文翻译来自于官方: http://docs.oracle.com/cd/E13222_01/wls/docs81b/adminguide/winservice.html
安装脚本在这里,%WL_HOME%\server\bin\installSvc.cmd,WL_HOME指weblogic程序的安装目录,
先创建一个脚本比如叫installWindowsServer.cmd,脚本放在你要注册的weblogic服务目录下面(weblogic服务目录: 在domains目录的weblogic服务目录下,有一个config目录,config目录下有一个config.xml文件),脚本如下:
里面要改几个参数
set DOMAIN_NAME=base_domain
set SERVER_NAME=AdminServer
set USERDOMAIN_HOME=C:\oracle\Middleware\user_projects\domains\base_domain
set WL_HOME=C:\oracle\Middleware\wlserver_10.3
设置服务的installWindowsServer.cmd脚本如下 :参考
@rem *************************************************************************
@rem This script sets up a WebLogic Server instance as a Windows service.
@rem It sets variables to specify the domain name, server name, and optionally,
@rem user credentials, startup mode, and arguments for the JVM. Then the script
@rem calls the %WL_HOME%\server\bin\installSvc.cmd script.
@rem *************************************************************************
echo off
SETLOCAL
set WL_HOME=C:\oracle\Middleware\wlserver_10.3
@rem Set DOMAIN_NAME to the name of the domain in which you have defined
@rem the server instance.
set DOMAIN_NAME=base_domain
@rem Set USERDOMAIN_HOME to the root directory of the domain's Administration
@rem Server, which is the directory that contains the domain's config.xml file.
@rem For more information about the root directories for servers, refer to
@rem A Server's Root Directory.
set USERDOMAIN_HOME=C:\oracle\Middleware\user_projects\domains\base_domain
@rem Set SERVER_NAME to the name of the existing server instance that you want
@rem set up as a Windows service.
set SERVER_NAME=AdminServer
@rem Optional: one way of bypassing the username and password prompt during
@rem server startup is to set WLS_USER to your system username and WLS_PW to
@rem your password. The script encrypts the login credentials and stores them
@rem in the Windows registry.
@rem The disadvantage to this method is that changing the username or password
@rem for the server instance requires you to delete the Windows service and set
@rem up a new one with the new username and password.
@rem If you use a boot identity file to bypass the prompt, you can change the
@rem login credentials without needing to modify the Windows service. For more
@rem information about bypassing the username and password prompt, refer to
@rem "Bypassing the Prompt for Username and Password" in the Administration
@rem Console Online Help.
set WLS_USER=
set WLS_PW=
@rem Optional: set Production Mode. When STARTMODE is set to true, the server
@rem starts in Production Mode. When not specified, or when set to false, the
@rem server starts in Development Mode. For more information about
@rem Development Mode and Production Mode, refer to
@rem "Starting in Development Mode or Production Mode" in the Administration
@rem Console Online Help.
set STARTMODE=
@rem Set JAVA_OPTIONS to the Java arguments you want to pass to the JVM. Separate
@rem multiple arguments with a space.
@rem If you are using this script to set up a Managed Server as a Windows service,
@rem you must include the -Dweblogic.management.server argument, which
@rem specifies the host name and listen port for the domain's Administration
@rem Server. For example:
@rem set JAVA_OPTIONS=-Dweblogic.management.server=http://adminserver:7501
@rem For more information, refer to
@rem "weblogic.Server Configuration Options" in the WebLogic Server Command
@rem Reference.
set JAVA_OPTIONS=
@rem Optional: set JAVA_VM to the java virtual machine you want to run.
@rem For example:
@rem set JAVA_VM=-server
set JAVA_VM=
@rem Set MEM_ARGS to the memory args you want to pass to java. For example:
@rem set MEM_ARGS=-Xms32m -Xmx200m
set MEM_ARGS=
@rem Call Weblogic Server service installation script. Replace <WL_HOME> with
@rem the absolute pathname of the directory in which you installed WebLogic
@rem Server. For example:
@rem call "D:\bea\weblogic810\server\bin\installSvc.cmd"
call "%WL_HOME%\server\bin\installSvc.cmd"
ENDLOCAL
备注:如果你使用域向导创建域和服务,一些域模板会提示你是否创建windows服务,选是,应会自动创建服务了,如果你想创建有依赖的管理服务,这里就要选否了,按本文的方法设置,无论你是选是还是选no,都会创建一个 namedinstallService.cmd 的脚本在服务的根目录,同上面的脚本是相似的
以上脚本真实有效,经本人测试,如有问题请留言,如有错误我会改正
下面是删除服务的脚本,官方的,没验证过
@rem *************************************************************************
@rem This script is used to uninstall a WebLogic Server service for a @rem server instance that is defined for the current domain. @rem The script simply sets the DOMAIN_NAME and SERVER_NAME variables and calls @rem the %WL_HOME%\server\bin\uninstallSvc.cmd script.
@rem *************************************************************************
echo off SETLOCAL
@rem Set DOMAIN_NAME to the name of the domain that contains the server. set DOMAIN_NAME=myWLSdomain
@rem Set SERVER_NAME to the name of the server that you want to remove as @rem a service. set SERVER_NAME=myWLSserver
@rem Call Weblogic Server service uninstallation script. Replace <WL_HOME> with @rem the absolute pathname of the directory in which you installed WebLogic @rem Server. For example: @rem call "D:\bea\weblogic810\server\bin\uninstallSvc.cmd" call "<WL_HOME>\server\bin\uninstallSvc.cmd"
ENDLOCAL