This how to is for people who are in the following situation:
- Using Windows 10 or Windows Server 2016+
- Running PhotoStructure for Node.js
Who want to have PhotoStructure start automatically as a Windows service.
- You won’t be able to see any error messages that appear on startup.
- If the service fails to start it’s difficult to troubleshoot why. It’s best to revert to manually running the script to troubleshoot rather than through the service.
- I’ve only tested this on one machine - there may be gotchas with other environments that this guide doesn’t cover.
- Get NSSM from here: NSSM - the Non-Sucking Service Manager
- Unzip NSSM to C:\Apps\NSSM or similar. You’ll need to use it from the command-line, so put it somewhere convenient.
- Download and install Git from here: Git - Downloads
- Make sure you have a working PhotoStructure for Node.js instance already, i.e. one you can start from a .sh script.
NB: I have a “test” PhotoStructure library in addition to my three normal libraries, and would highly recommend this principle in general. My “test” library is simple with a few photos - it’s always safer to try new unproven things on a test library than your real (“production”) library, in case something goes wrong, such as with these steps below…
- Open an Administrative Command Prompt
- Change directory to wherever you installed NSSM and the win64 subdirectory, e.g. C:\Apps\NSSM\win64
- Run “nssm install PS-Library” (replace “PS-Library” with whatever you want the service to be called)
- In the popup window that appears, enter the following:
- Path: C:\Program Files\Git\bin\sh.exe (if you installed Git to a different path, change this to match)
- Startup directory: C:\Apps\PhotoStructure (the folder your PhotoStructure start .sh script is in)
- Arguments: C:\Apps\PhotoStructure\start-test.sh (the path to your PhotoStructure start .sh script)
- Go to the Details tab and make sure Startup type is “Automatic”.
- Go to the Log on tab and select “This account”, then enter a valid account. This may be a local administrator account, or the same account you use to sign into your computer with. Note - for me, the service did run as “Local system”, but it had some weird issues with settings being lost, I found it worked better signed in as my normal user. If you use a Microsoft account to sign-in that’s fine, enter the email address here and the password as you would normally.
- Click “Install Service”.
Last Step: Test it works
To test, either:
- Run “nssm start PS-Library”, or;
- Open services.msc, locate your service, and right-click then select Start.
Your service should start and stay started. If it stops, something isn’t working properly.
Wait 10-20 seconds for your library to start (depending on the speed of your computer), then browse to your PhotoStructure library in a web browser and make sure it’s working as expected.
Done! Now if you restart your computer, PhotoStructure should be running and available before you even login - just remember to allow enough time for it to start up before testing it.
- Make sure you didn’t add any double-quotes around the path or arguments for the service.
- Open services.msc, double-click your service then select the Log On tab, and re-enter the credentials. Click OK to save the service, and try start it again. The account may not have been granted the “Log on as a Service” permission correctly. This should ensure it does get granted the permission.
- Open a Command Prompt, and run “C:\Program Files\git\bin\sh.exe” and ensure a new $ command prompt appears, like so:
- If the $ command prompt appears, type “exit” and press Enter to quit. That’s good. Now try run the script to start PhotoStructure directly:
- In a Command Prompt, run “C:\Program Files\git\bin\sh.exe” “C:\Apps\PhotoStructure\ps-start.sh” (replace with your PhotoStructure start script). Does PhotoStructure start? If so, then there’s a problem with the service. If PhotoStructure doesn’t start, then troubleshoot why PS isn’t starting for you.
- PhotoStructure now picks up photos from locations I didn’t expect? I had this happen when I ran it under Local System rather than my normal account. If it still happens to you, add a “.nomedia” file to the folder that is unwanted in your library. Check your PhotoStructure settings are still correct too.
Should you wish to change the service settings, it’s very easy. Just open an Administrative Command Prompt, and go to the NSSM\win64 folder again, and run:
- nssm edit PS-Library (again replace with your service name if you changed it)
Then you can edit the existing service without deleting and re-creating it.