1. Close any instances of the UniFi software on the controller
  2. Open the command prompt as an Administrator
  3. Locate the java installation directory.
    On 32-bit machines, it's usually found at “C:\Program Files (x86)\Java\jre7\bin”;
    For 64-bit machines, “C:\Program Files\Java\jre7\bin”
  4. Add the dir above to the PATH (as seen under Computer->Properties->Advanced system settings)
  5. Change directory using the command “cd <unifi_base>”
  6. Type “java -jar lib\ace.jar installsvc”


 https://community.ubnt.com/t5/UniFi-Controller-Installation/UniFi-Run-the-controller-as-a-Windows-service/ta-p/412667