Now there is a requirement to make a newlisp script file into a Windows Service and start it automatically upon startup. Check the system environment and whether other processes are still running.
To run newlisp on Windows, you need to execute a command similar to this:
newlisp a.lsp
Therefore, write a BAT file to execute the above command. In this way, the problem is converted to how to install the BAT file into a Windows Service. The following is a detailed example.
Assume there is a daemon. LSP file with the following content:
(while true (println "hello, I am daemon") (append-file "c:\\t.txt" "mm") (sleep 1000))
Write "mm" to the file c: \ t.txt every 1000 ms"
Write another daemon. BAT file with the following content:
newlisp C:\windows_service\daemon.lsp
Make sure that the absolute path is used to ensure that no error occurs when running Windows service.
Now download the nnsm program: http://nssm.cc/download? Page = download
After decompression, select a 32-or 64-bit program based on the platform and copy it to the Windows/system32/directory.
Run the following command:
nssm install my_daemon C:\windows_service\daemon.bat
The installation is successful.
Run the following command when starting:
net start my_daemon
Nssm.exe cannot be deleted or moved.
It is easy to uninstall Windows service.
nssm remove my_daemon confirm
Done.