Search This Blog

Monday, May 14, 2012

Install a service – windows server 2008

Edit
  1. Run Regedit or Regedt32.
  2. Find the registry entry “HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services”.
  3. Look for the service there and right click on the properties which you want to modify.
Delete
  1. Run Regedit or Regedt32.
  2. Find the registry entry “HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services”.
  3. Look for the service there and delete it. You can look at the keys to know what files the service was using and delete them as well (if necessary).
Install (via command prompt)
  1. At a command prompt, type: installutil <Path of the Service>
Examples:
  • for .net v1.1:
    C:\> C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\InstallUtil.exe C:\MyService.exe
  • for .net v2.0: 
    C:\>C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\InstallUtil.exe C:\MyService.exe
Install (via bat file – .net v2.0 example)
  1. Save the example code as a bat file.
  2. Place the bat file in the same folder as your service exe file.
  3. Run the bat file.
@echo off
echo Starting installation..
pause
REM SET LOGFILENAME=log_%DATE:~4,2%%DATE:~7,2%%DATE:~10,4%_%TIME:~0,2%%TIME:~3,2%%TIME:~6,2%.txt
REM date /t >> %LOGFILENAME%
REM time /t >> %LOGFILENAME%
REM pause
echo Current directory..
cd
pause
cls
echo YourServiceName in
cd
pause
C:\Windows\Microsoft.NET\Framework\v2.0.50727\InstallUtil.exe YourServiceName.exe
pause
cls
echo Installation completed..
pause

Running JBoss AS 7 as a Windows service

There are a few threads touching this topic but I thought I'd summarize my findings so far in getting JBoss AS 7 up and running as a Windows service.

First of all, grab the appropriate native connectors from http://www.jboss.org/jbossweb/downloads/jboss-native-2-0-10 (x86 for 32bit host, x64 for 64bit). Unzip the archive in the JBoss main folder. Then make some modifications to the service.bat file

  1. Rename the SVCNAME, SVCDISP and SVCDESC to something more meaningful. This is optional but if you plan to install multiple servers (e.g. test and production, you want different names.
  2. Modify the JAVA_OPTS to increase memory, service.bat doesn't read any other conf.bat file so it will use default memory settings and will die of memory loss for a mid-sized deployment. Keep the -Xrs setting as I've seen cases where a RDP logout has caused JBoss to shut down. You might also want to add a JAVA_HOME if it's not set as a system wide environment variable
  3. Change all run.bat calls to standalone.bat calls as they are called nowadays
  4. Comment out all "call shutdown" calls and replace then with call jboss-cli.bat --connect command=:shutdown >> shutdown.log 2>&1. This is especially important because the shutdown.bat that was around before is no longer there and it will probably run shutdown.exe from system32 instead, causing a server shutdown. If you run multiple servers you must config the CLI script to connect to the correct management ports set in standalone.xml by adding a --controller=host:mport to the bat call.
  5. Install the service with "service install". You might also want to change the service starting mode to "automatic" and change the "run as" to a normal user. Note that on later Windows-versions, you must run the executing cmd in administrator mode.