redpois0n
redpois0n

Reputation: 131

C# Console Executing

i would like to have help with this.

Lets say that i want to launch a .jar file trough a bat, like

java -Xms1024M -Xmx1024M -jar craftbukkit-0.0.1-SNAPSHOT.jar nogui

Like that.

When i press the bat, It would load in the bat file. But lets say, that i want to create a console application that when a user presses a button, the console launches the java arg inside the console.

Please help, if you dont understand then i explain more.. Sorry for bad english

~~ redpois0n

Upvotes: 0

Views: 156

Answers (2)

Fender
Fender

Reputation: 3055

look here for starting a process from c#:

http://www.csharp-station.com/HowTo/ProcessStart.aspx

just create a instance from Process and give it the name of your application and all parameters and then call start

just use this code:

using System;
using System.Diagnostics;

namespace csharp_station.howto
{
    /// <summary>
    /// Demonstrates how to start another program from C#
    /// </summary>
    class ProcessStart
    {
        static void Main(string[] args)
        {
            Process java = new Process();

            java.StartInfo.FileName   = "java";
            java.StartInfo.Arguments = "-Xms1024M -Xmx1024M -jar craftbukkit-0.0.1-SNAPSHOT.jar nogui";

            java.Start();
        }
    }

}

Upvotes: 2

bmosh
bmosh

Reputation: 176

Here's a nice command line helper that might help you out. You can use this in your console application to launch your process.

http://www.codeproject.com/KB/string/CommandLineHelper.aspx

Upvotes: 0

Related Questions