Wednesday, February 4, 2015

OpenOffice as windows service

Running "OpenOffice headless" as a service in Windows

OpenOffice is a great third party tool used for Document preview generation. 
I have been using this tool in number of applications like Liferay, Alfresco, Drupal etc
In all these applications it have feature to show previews online on the portal. For generating preview we need OpenOffice to run in headless.

It is always be annoying to run OpenOffice headless manually. That is why we need a smooth running service of this application in the background.

You can easily configure OpenOffice headless as a windows service. 

How to begin

My environment detail:
Operating System - Windows Server 2008 
OpenOffice - 3.4.1

Follow the steps to create windows service.

  • Download srvany.exe and copy it in C:\Windows\system32 folder. You can also extract srvany.exe from Windows Server 2003 resource Kit 
  • Go to command prompt. You should have administrator privileges to perform this activity. 

    Command Syntax

    C:\Windows\system32>sc create "openoffice" binPath= "\"C:\Program Files (x86)\OpenOffice.org 3\program\soffice.exe\" -headless -nologo  -nocrashrep -norestore -accept=\"socket,host=127.0.0.1,port=8100;urp;\" -nofirststartwizard" DisplayName= "OpenOffice 3.x Server" start= auto

    [SC] CreateService SUCCESS

  • Open Registry Editor (regedit) and Navigate to HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\services\openoffice
  • Copy the value of the ImagePath to the clipboard.
  • Alter the value of ImagePath to "C:\Windows\System32\srvany.exe"
  • Add a new Key named "Parameters", this is essentially a folder.
  • Add a new String Value named "Application" and set the value to the clipboard contents copied from the ImagePath.

  • Start the service openoffice. 
  • Check if the open office service is started and running fine.

  • Command Syntax
    C:\windows\system32>netstat -nao |findstr -c ":8100"
    TCP       127.0.0.1:8100         0.0.0.0:0              LISTENING       7856