Windows services are applications configured to run in the background, and optionally automatically when the computer starts. They are most commonly used with server style applications on the server OSs, such as Windows Home Server or Windows Server 2003 or 2008, but all modern Windows OSes have the feature.
bliss is a automatic music organiser that runs in the background and delivers its UI via a Web browser. This makes it an ideal candidate for installation as a Windows service. Because it is fully automatic and 'watches' your music collection for additions, removals and changes it makes sense to run bliss automatically at start up. This way you can set your rules and forget about them... at least until your music library needs re-organising again! Before the new Windows service, the only way to have bliss start automatically at startup was to run bliss as a scheduled task.
Installing the Windows service is really easy; you just need to run a batch file. Here's how:
This varies slightly depending on whether you are running Windows Vista or Windows 7.
Locate the folder in which bliss is installed, and then the
bin folder therein.
bin folder you should see (amongst other files)
Simply double click
install-service.bat or right click then Open from within
A black DOS box will popup with some commands and will probably close before you have time to read what actually happened... scroll down if you're interested in what the script does.
Now check the services applet (Control Panel → Administrative Tools → Services). The bliss service should appear:
You can now start and stop bliss via the 'Play' and 'Stop' buttons on the services applet. Note that bliss does not appear in the System Tray when started as a service. This is because bliss is running as the 'LocalSystem' user, rather than you that is logged in. You can see the bliss process, however, if you look in the Task Manager. And, of course, you can connect to it with your browser.
bliss defaults to start automatically on system startup. You can alter that by right clicking the service, choosing Properties and changing the Startup type to Manual.
You can, of course, still start and stop bliss via the Start menu after the service is installed.
The big difference here is that you must run
install-service.bat as the administrator.
Locate the file inside the bliss installation folder, inside the
bin folder, right click
it and Run as administrator:
You'll receive the confirmation Do you want the following program to make changes to this computer?. Click Yes (assuming you do) and the service will be installed. Like with earlier versions of Windows, a command box will briefly spring up. Read below for what the batch script is doing.
Now check the services applet (Control Panel → Administrative Tools → Services or
services into the Search programs and files text field in the Start Menu).
Removing the service is done via the
remove-service.bat file. Again, on more recent
versions of Windows this must be run as Administrator.
If you have the services applet open when
remove-service.bat is run you will have
to refresh the applet to see the bliss service disappear.
Both scripts use an open source application called Procrun to both install and remove the service and be the conduit through which the service is started and stopped.
install-service.bat script simply calls Procrun to install the service:
@echo off rem Batch script to install bliss as a service in the Services applet. rem By default is set to run automatically on reboot. This can be changed by rem altering the STARTUP parameter below from "auto" to "manual" or, post rem installation, using the Services applet via Service properties. setlocal set INSTALL_HOME=%~dp0.. set STARTUP=auto rem Must change directory for Windows 7 which defaults to System32 dir when rem run as administrator cd %INSTALL_HOME%\bin prunsrv.exe //IS//bliss --DisplayName="bliss" --Description="Automatic music library organiser" --Startup=%STARTUP% --StartMode=exe --StartImage="%INSTALL_HOME%\bin\bliss.exe" --StopMode=jvm --StopClass=com.elsten.bliss.main.StopService --Classpath="%INSTALL_HOME%\lib\com.elsten.bliss.runtime.jar" endlocal
If, for whatever reason, this doesn't fit well in your system (maybe you'd prefer a different name or description for the service), feel free to edit the script and let me know in the comments how it could be improved!
remove-service.bat script simply calls procrun to remove the service:
@echo off rem Batch script to remove bliss as a service from the Services applet. rem This does *not* uninstall bliss. setlocal set INSTALL_HOME=%~dp0.. rem Must change directory for Windows 7 which defaults to System32 dir when rem run as administrator cd %INSTALL_HOME%\bin prunsrv.exe //DS//bliss endlocal
Check out the Procrun documentation for more detail about the parameters you can pass to Procrun.
One thing I've noticed is that this won't work if you are running bliss on a mapped drive. This is because the mapped drive is 'owned' by you, the user in Windows that you login as. When a service executes, it executes as a separate user, LocalSystem, which does not have access to the mapped drive. You need to install bliss to one of your local hard drives for it to work.
Oops! There's a workaround, and that's to use the
sc.exe Windows command. Simply open a command terminal (in Windows 7, do
this as Administrator) and type:
sc delete bliss
And the service should disappear. Note: if you already have the services applet open, you may need to refresh the services list to make the bliss service disappear.
Thanks to AndyAmstrong for the image above.