1. This forum is obsolete and read-only. Feel free to contact us at support.keenswh.com

Services command prompt control for servers.

Discussion in 'Groups & Dedicated Servers' started by gimmilfactory, Jun 13, 2014.

Thread Status:
This last post in this thread was made more than 31 days old.
  1. gimmilfactory

    gimmilfactory Junior Engineer

    Messages:
    523
    I have looked thoroughly, and did not find it anywhere. So I thought I would
    let everyone know, that it is possible to script a start and stop sequence
    for your server.

    This post:
    https://forums.keenswh.com/post/running-dedicated-server-as-a-service-with-parameters-6925929?highlight=service&trail=15

    ...goes in to some detail about services interface and the fact that the game starts and creates as one.
    But what does that mean?
    It means you can have a batch script on your desktop for starting and stopping your server,
    with one (double)click.

    Yeah, you have the ability through the services.msc menu to auto-start with windows, disable, or manual
    start; That's great and all, but what good is manual mode without having to go into a menu?


    Command Line Control: Service Control is not only
    available through UI, you can script it as well..

    I've noticed some Windows OS types need the full path, others allow you to
    utilize the short command of "sc". The full path of this is C:\Windows\System32\sc.exe
    if "sc" does not work for you.

    Creating a Batch Script. Easy; Say your instance name is "Instance1".
    Create a new notepad document.
    Save As.."Instance1 Start.bat" and *All Files instead of .txt for file format.

    Start Function
    Type:
    echo Starting Dedicated Server...
    sc start Instance1
    exit

    SAVE IT AGAIN.
    That's it!

    Want a Stop Function? do the same thing but name the
    batch file differently and say stop, of course.

    Type:
    echo Stopping Dedicated Server...
    sc stop Instance1
    exit

    SAVE IT AGAIN.
    That's it!

    Restart Control? If you want a restart option, just combine the two,
    stop then start, and of course rename the batch file something reasonable.

    Taking Further Control: It is fully possible to reconfigure the name of a
    service which is listed and configured in your system services menu, it also happens to
    be sourced from and control the name of each instance that the server editor lists.

    Changing the Instance & Service Name is very easy.
    Open a command prompt window (Start>Run | Type cmd & hit enter)

    1st step:

    Type:
    sc delete "<CurrentInstanceNameHere>"
    You will get some confirmation feedback.

    Type:
    sc create "<NewInstanceNameHere>" start= auto type= own binPath= "C:\<Install\Dir\Tree>\DedicatedServer64\SpaceEngineersDedicated.exe"

    *Use 64/32 Data Dir accordingly.
    *Ensure that the P is capitalized.

    2nd step:
    Navigate to your saves directory. This is usually C:\ProgramData\SpaceEngineersDedicated or
    C:\Users\<Account Name>\AppData\Roaming\SpaceEngineersDedicated
    Change the folder name to whatever you renamed your instance to.

    That's it! As soon as you re-open the DS configuration tool,
    your new instance name will appear.

    Want the description back in the services.msc UI?
    Type: sc description "<InstanceNameHere>" "Your place for space engineering, destruction and exploring."

    The only thing that does not work:
    If you notice, I have you change the save directory name. This is because you can not change
    the binPath= to include the
    "-path C:" attribute that the developers have just implemented for
    location control, within the service parameters. I have tried many-o-sorts of configuration settings
    and passing parameters within the services UI properties for my instance, and it just sits there half
    loaded with an empty level.

    One is supposedly able to pass arguments while using the "sc" function (e.g. sc start Instance1 -path "C:\Test\Instance1\"),
    but that does nothing for your initial boot services start-up.

    Originally I set out to figure any sort of control of having the ability to rename instances
    while maintaining the configuration control interface, and all while being able to
    set custom save paths for my game instance saves. I have tried editing the registry keys directly,
    and adding a parameters key with both -path C:\ and path C: for the string names and values,
    but all with no avail.

    I will be updating this post if I find out more on how to overcome this wall.

    Enjoy! :D
    *Update 6/14

    There is still no head-way on using a full server control argument within binPath, it just ends up spitting out
    "the service did not respond to the start or control request in a timely fashion" and the instance exits,
    even though I see:
    A) See CPU being fully used.
    B) RAM starts being utilized.
    C) In Interactive Desktop mode for the service, I get:
    [​IMG]
    I have found out in the least, that the service DOES start, and it DOES begin loading the instance at the location I choose by doing this,
    it does not however get me any closer to getting it work, but at least I know it is working how it should, it is either something with a control request not being responded to because of how the program is written, or that the "Loading" of the server is not the response, but the "Game Ready" one is.
    I do not however see how that would be different from letting the instance EXE choose the path by instance name, and why that works A-OK.
     
Thread Status:
This last post in this thread was made more than 31 days old.