Jump to content
TrinityCore

How to launch the trinitycore server from a c# app ?


Eternalis
 Share

Recommended Posts

Hello.

I'm working on some kind of admin app in c# to allow my crew and myself to start/stop the servers and update files in the core folder remotely, but i can't figure out how to start the server.

When i'm trying to do so, I can see something launching in my taskbar but it immediately close and the log for the server file does not update.

On the C# side the process code tell me that the process started successfully and it is working with other softwares so i guess it does not come from there.

I suppose it is the server that is closing immediately. Is there something specific to know when starting the server from another app ?

Here is the c# code if it can help to find the problem :

           if(p_command.Equals("StartServer"))
            {
                LogMessage("Starting server...");
                Send(handler, "ServerStarting");
                try
                {
                    using (Process myProcess = new Process())
                    {
                        myProcess.StartInfo.UseShellExecute = false;
                        myProcess.StartInfo.FileName = ConfigurationManager.AppSettings["corePath"] + "/authserver.exe";

                        myProcess.StartInfo.WorkingDirectory = ConfigurationManager.AppSettings["corePath"]; //This line solved the problem
                        myProcess.Start();
                    }
                }
                catch (Exception e)
                {
                    LogMessage(e.Message);
                }
            }

 

Edit : I found the solution.

By starting the process from my c# app, it wasn't setting the working directory of the server automatically which caused it to not find the dll, ...

The solution to this problem is the line pointed above.

Have a nice day !

Edited by Eternalis
Update with the solution
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...