Game Development Community

Is it possible to run a DOS batch file via GUIButtonCtrl()?

by James Owen · in Torque Game Engine · 11/20/2004 (9:47 am) · 6 replies

Eg. I have a batch file DedicatedServer.bat

what should I put in command="***** "; below so that I can run a batch file (if possible)? Or can batch file be run in .cs file?

new GuiButtonCtrl() {
profile = "GuiButtonProfile";
horizSizing = "right";
vertSizing = "bottom";
position = "420 280";
extent = "125 20";
minExtent = "8 8";
visible = "1";
command = "****************";
helpTag = "0";
text = "Run Dedicated Server";
};

Thank you.

#1
11/20/2004 (1:25 pm)
Why would you need to? You should be able to easily shut down a client while starting a dedicated server from the same button like that. There really is no difference in a dedicated server when it all comes down to nuts and bolts. All thats really done is NOT loading the GUI's and client control functions. Which of course could be shut down and then deleted, after that, set the $Server::Dedicated = "True"; variable and it should be exactly the same with the exception of a few extra namespace definitions that may still be stored in memory.(not sure if the resource manager releases them when the objects are deleted or not)
#2
11/20/2004 (2:19 pm)
James Owen, as Gonzo said you can create a dedicated server with much less effort and have it look cleaner and more controllable.

You could however create a consolefunction that calls cmd("rundedicated.bat"); or whatever it is that you want to execute.

I think that is the right syntax, but I'm not sure how the application will react when you run this. I think it will keep going until the dedicatedserver.bat is dead and that could take a while. Might be worth looking into if that's what you want to do.
#3
11/20/2004 (2:39 pm)
Basically, I want to allow player the ability to choose the map they want to run as a dedicated server through a GUI interface. Would it be right to say I need to create a dedicatedserver.cs file with the following code?


Exec ("dedicatedserver.cs");

consolefunction ds() {

cmd ("rundedicated.bat");

}

new GuiButtonCtrl() {
profile = "GuiButtonProfile";
horizSizing = "right";
vertSizing = "bottom";
position = "420 280";
extent = "125 20";
minExtent = "8 8";
visible = "1";
command = "ds()";
helpTag = "0";
text = "Run Dedicated Server";
};


Also, any way to kill the batch file in the GUI interface via buttons?

Thanks for the suggestions.
#4
11/20/2004 (3:10 pm)
No. To call a cmd you need to do it through C++ and the source of Torque Game Engine.

I still don't think you want to do it this way. Take a look at the createServer(); scripts of the demo, you can do exactly what you want from there :) It's really easy when you find the function and start playing around with it.

Good luck!

Edit: I'm pasting some script-code.. sec.

Alright. Make a button which calls a function. And place something like this inside the function:

destroyServer();
portInit($Pref::Server::Port);
allowConnections(true);
onServerCreated();
$ServerGroup = new SimGroup(ServerGroup);
loadMission(%mission, true);

That should get you started. Make sure you enabled the consoleWindow if that's what you want too.. I think that is enableWinConsole(true);
#5
11/21/2004 (1:29 pm)
Thanks Stefan Lundmark, that helps :)
#6
11/25/2004 (4:28 am)
Kinda kills the cross platform effect ....