Running TerrariaServer.exe via Command Line

Discussion in 'In-Game Support Archive' started by ChrisPls, Jun 2, 2011.

  1. ChrisPls

    ChrisPls Green Slime

    I'm having a really hard time getting this to work. Right now, I think the biggest issue is spaces in folder names like "Program Files (x86)".

    Batch file I'm trying to use (with ugly workarounds because spaces suck).

    @echo off
    cd C:\Users\Chris.Owner-PC\Documents\My Games\Terraria
    start 'C:\Program Files (x86)\Steam\steamapps\common\terraria\TerrariaServer.exe' -port 7777 -players 10 -pass -world world1.wld
    The problem right now?
    The system cannot find the file 'C:\Program.
    I've been playing with this for about half an hour, so there have been other errors. Glancing over them... they usually involve finding files/folders.

    I'm starting to think ALL of my problems would be solved if there was a way for me to pass strings to the program. I'm pretty sure 'foo' and "foo" work on my Linux sides, but they just screw things up here. :(

    Simply running the executable via the batch promps me for information - ports, etc - but I want a single batch file to start my server.

    Any advice? :(


    Playing around with more stuff, new error.
    Unhandled Exception: System.IndexOutOfRangeException: Index was outside the boun
    ds of the array.
      at Terraria.ProgramServer.Main(String[] args)
    @echo off
    cd  C:\Program Files (x86)\Steam\steamapps\common\terraria
    set world = C:\Users\Chris.Owner-PC\Documents\My Games\Terraria\Worlds\world1.wld
    TerrariaServer.exe -port 7777 -players 10 -pass '' -world %world%
    I'm familiar with what args[] does... is this a coding error(i.e., wait for the patch) or does it have issues with my arguments?
  2. chopper

    chopper Green Slime

    Not sure about the new error, but for the first you can use the windows short path name. Windows still allows access to files using the old DOS 8.3 file naming convention. The path will be something like "C:\Progra~2\Steam\steama~1\common\terrar~1". It uses the first 6 letters of the long name and appends a ~1, ~2... It may only append the number to files and directories longer than 8 characters, so I think "terrar~1" might just be "terraria" as it is only 8 letters. Unfortunately I don't know an easy way to have windows tell you the short path name. More info can be found by searching "windows short path name" no quotes probably.
  3. lunboks

    lunboks Squirrel

    Single quotes in batch files? What is this sorcery? That's not even a thing you can do.

    My suggestion: Make a serverconfig.txt (a default one should be in the same directory as TerrariaServer.exe) instead of passing it everything as a command line. Then do:
    TerrariaServer -config <config file>
    You don't even need a batch file for that, a shortcut would suffice. If you want to delve into the arbitrary syntax insanity that is Windows Batch files, here's how you'd do it:
    start "" "<path>\TerrariaServer.exe" -arguments and -stuff
    The reason for this is retarded: If you need to put the path to the executable file in quotes, you have to specify a title. TerrariaServer.exe sets its own title anyway, so it wouldn't matter.
  4. ChrisPls

    ChrisPls Green Slime

    Short path names sound amazing, thank you for that.

    I tried using the default config file... and it failed horribly. The settings weren't commented, but they didn't seem to take any effect. :/

    I should be able to use my current arguments in a shortcut as well, shouldn't I? I guess I find batch files easier to deal with. :s

    That's so weird.... But thanks, certainly will make things easier in the future.
  5. Looty

    Looty Cursed Man

    I have had an error that crashed the server boot each time I tried to load it. Turns out the world path was wrong. I'm using Windows 7, the documents folder is just called "Documents", not "My Documents". Changing it started the server as I wanted it.

    If you use the default serverconfig.txt, no arguments are passed, so on launching TerrariaServer.exe there will be the default prompts you get when starting it from the folder.

    As a guideline for everybody else who doesn't want to use Windows batch files but rather stick with the serverconfig+shortcut system:

    Setting up a server
    using a Steam shortcut and not having to enter parameters anymore

    |1| Make a serverconfig file in *.txt format. Go to your Terraria folder (...\Steam\steamapps\common\terraria\), copypaste "serverconfig.txt" and rename it to a name of your liking such as "myserverlol.txt".

    Open the file with a text editor, all parameters are commented out (#). Uncomment the parameters you don't want to be set to default by removing the # character. Change the parameters to your liking. Define custom ports, set a cool message of the day (motd) until you're satisfied.

    world=C:\Users\[MyName]\Documents\My Games\Terraria\Worlds\world3.wld
    motd=Don't chop down the trees please! Only iron armor.
    #This is commented out so I can write whatever I want. Penis, lol.
    MAKE SURE to get the world path right if you want to use a predefined world (which you will want to). Actually open up your documents folder and look for it, then compare the paths. A wrong path will crash your server. And worlds are saved like world1, world2, without names, so don't mix them up.

    |2| Create a shortcut
    a) For shortcuts you can start from Windows without using Steam, create a shortcut to TerrariaServer.exe anywhere you want, name it after your world if you wish. Right-click, go to properties. Behind the target name (".../TerrariaServer.exe") add a space and the "-config" parameter followed by your serverconfig file. In this case that's
    ".../TerrariaServer.exe" -config myserverlol.txt
    b) If you'd rather use the Steam library, add a shortcut in Steam. On the menu bar at the top click on "Games". Then "Add a Non-Steam Game to My Library..." Select TerrariaServer.exe in your Terraria folder. Right-click > Properties:
    • Change the target name to include your config, like in a).
    • Name it differently so you know what world you're starting ("TerrariaServer - LootyWorld (port 7783)").
    • Set an icon if you wish. Looks better.
    Now you can start this bitch from the quick list whenever you want. It will open the world you specified on the port you set it to without asking for further input.

    >> Use a different port for each world because the in-game server list only shows the name of the last world you visited when joining the IP+Port. If you have 10 worlds, assign each to an own port using a different config file so the game will show the correct world name in the server list. Aye? Aye.

    Edit: No, I just realized Steam doesn't obey rules. If you add TerrariaServer.exe it will use any config file it wants without listening to what you tell it. If you simply start it from the folder, it doesn't, it just works like it should. Steam cannot handle applications like it is supposed to, so just stick to creating Windows shortcuts for each server you want to quickstart.

Share This Page