Jump to content

custom link with a server stop


dimitrifrom31

Recommended Posts

I was given a code made by Luis to run an exe via a button on the Panel.

 

Only "problem" is that the server is not stopped before the exe is ran, that was not a big deal for my previous usage but for the one I want to make now I really need the server to be stopped so here is the code if any1 can help :

 

<%
'''''''''''''''''''''''''''''''''''''''''''
'Variables
'''''''''''''''''''''''''''''''''''''''''''

Dim pageTitle As String = "MyCustomProgramName"
Dim stopGameServer As Boolean = False
Dim relativePath As String = ""
Dim command As String = "cd %path%" + vbnewline + "%path%\MyCustomProgram.exe"
Dim startMessage As String = "The program is running please wait...<br>"
Dim endMessage As String = "Operation terminated successfuly.<br>You can close this window."

'''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''

Response.Write("<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0 Transitional//EN"">")
Response.Write("<HTML><TITLE>" & pageTitle & "</TITLE><BODY bgcolor=""#000000""><font face=""Lucida Console"" size=""2"" color=""#FFFFFF"">")

If TCAdminSDK.Web.Session.IsAuthenticated Then
Dim serviceid As String = Request.QueryString("serviceid")
Dim service As New TCAdminSDK.Objects.Service
service.ServiceID = serviceid
If service.Find Then

Dim path As String = System.IO.Path.Combine(service.AutomationFilesPath, relativePath)
command = command.Replace("%path%", path)

Response.Write(startMessage)
Response.Flush()

If service.UserID = TCAdminSDK.Web.Session.CurrentUser Or TCAdminSDK.Web.Session.CurrentUserType = TCAdminSDK.Objects.UserType.Admin Or TCAdminSDK.Web.Session.CurrentUserType = TCAdminSDK.Objects.UserType.SubAdmin Then

Dim serviceWasRunning As Boolean = False
If stopGameServer And service.CurrentStatus = TCAdminSDK.Objects.ServiceStatus.Running Then
Response.Write("Stopping the game server...")
Response.Flush()

service.Stop()
serviceWasRunning = True
End If

Dim serverplugin As TCAdminBase.Plugins.IGenericPlugIn = TCAdminSDK.Remote.InstanceCreator.GetPluginFromServer(service.ServerID, "TCAdminMonitor.StandardPlugins.RemoteServers.ServerUtilities")
serverplugin.Execute(New Object() {"ExecuteScript", service.WorkingDirectory, command})

If serviceWasRunning Then
Response.Write("Starting the game server...")
Response.Flush()
service.Start()
End If
End If

Response.Write(endMessage)
Response.Flush()
End If
End If

Response.Write("</font></BODY></HTML>")
%>

 

Note that I noticed that this code is supposed to stop the server but it just doesnt so there must be some typo or error somewhere.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Terms of Use