In order to connect to LM Studio from your LAN, and use programs like Chatbox with it, you need to start its server mode, and enable CORS: https://lmstudio.ai/docs/api
However, currently there is no simple way to start LM Studio on PC startup, without logging in as a user. You can if you auto-login by following these steps: https://lmstudio.ai/docs/api/headless
However, I want to start the PC remotely (via Wake-on-LAN), and be able to connect to LM Studio, select the desired model and use it, without logging into the PC.
Here's what we can do:
1. Download NSSM: https://nssm.cc/ and copy it to "C:\Program Files\nssm" for convenience.
2. Identify the location of lms.exe. In my case it's in "%UserProfile%\.cache\lm-studio\bin". Replace "%UserProfile%" with the real path for your system (e.g. "C:\Users\MyUser").
3. Navigate to "%UserProfile%\.cache\lm-studio\bin" and create the following file named lms-startup.bat. Add the following code to it and save it:
@echo off
lms.exe server start --cors
pause
4. In a privileged command prompt, run nssm install and you will get a GUI for creating a new Windows Service:
5. Under Path select the path of the lms-startup.bat file, Startup Directory should be the same path. Under Arguments leave blank. Under Service name add "LMStudio":
7. Under the Exit actions tab, set "Delay restart if application runs for less than 0 ms"
8. When you're done, click Install service. The new service should be visible under Windows Services and should start on boot (note that there isn't a graceful way of restarting/stopping the service).
Comments