[C#]How do i...

Newbie Spellweaver
Joined
Mar 18, 2008
Messages
12
Reaction score
0
Ok herse my problem i whana do a program starter/stoper

i alredy have the starting part
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 notePad = new Process();

 notePad.StartInfo.FileName   = "notepad.exe";
notePad.StartInfo.Arguments = "ProcessStart.cs";

notePad.Start();
}
}
}

But how do i close this program whonse i have it runing?

sory for my eng
 
Ok herse my problem i whana do a program starter/stoper

i alredy have the starting part
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 notePad = new Process();
 
 notePad.StartInfo.FileName   = "notepad.exe";
notePad.StartInfo.Arguments = "ProcessStart.cs";
 
notePad.Start();
}
}
}

But how do i close this program whonse i have it runing?

sory for my eng

Hey, what program are you using to edit/create the C#? then maybe i will be able to help.

Regards
Vynsan
 
You could do
class ProcessStart
{
Process process = new Process();

static void Main(string[] args)
{
process.StartInfo.FileName = "file.exe";
process.StartInfo.WorkingDirectory = "directory";
process.StartInfo.Arguments = "commandline (s)";
process.Start();

process.WaitForExit();

if (process.HasExited)
{
// do somethen when close ? eg restart it
process.Start();
}
}
}

im unsure what you trying to do :)
 
im unsure what you trying to do :)

im trying to make a server starter that can open and close the server's i can start the server but im in a dead end when it comes to close it

Command's:
Start = starts all server's
Stop = stops all server's
 
You can send a kill signal to the process if you know what process ID is assigned to the server. That's how I wrote a control panel for a game/webserver that could automatically start/stop apache, MySQL, etc. How to find the specific process ID and send a kill signal to it in C# is something you'll have to figure out yourself tho' :smile:
 
Back