I am trying to put up a realtime server with php -q c:\inetpub\wwwroot\os\realtime\server.php
. The problem is that this command is infinite, so once the Power Shell window is closed the command stops and so does the server. I tried to use a batch file, but that is the same as typing it in.
The server is at my work, so no person is allowed to stay logged in for an extended amount of time. Once I logout the command terminates. Any help would be greatly appreciated!!
Run your batch as a service
You can install your batch as a service (which will be independent from a logged user), check this link.
For that you'll need to install additional software.
Run a Schedule Task with SYSTEM Account
Simple, just don't use user accounts. Schedule a task with the Task Scheduler
in Windows and in the field of the user put the NT AUTHORITY\SYSTEM
account which has higher privileges than an administrator and it's always active.
In the task use your batch file and configure the task to run it in every start of the machine. (run it manually the first time), so next time the server/desktop is restarted the batch will ran automatically.
Here is useful information about how to do it through command line.
And here's a picture of how it may look in your system:
If you don't know if your batch is being executed correctly I suggest first creating a simple batch to write an empty file in a known location or echoing text into some text file.
If that works, then start adding your batch/php parameters. It could happend that the command "php" can't be found because environment variables or that you need to provide an absolute path.
Isn't clear in your question but I'm assuming you aren't running any GUI.