[C#] Restart Problem
#1

Hey guys, ive tried to make an restarter for my Server with C#, all is good but there is one problem but a big^^

 

So then i press a button it start all Server and check if the Process "connector" exist

how can i make that it dont only check if i press a button?

 

Aktually Code :

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using System.Threading;
using System.Runtime;
using System.Timers;
using System.IO;
using System.Web;
using System.Net;
using System.Windows;

namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private bool CheckIfAProcessIsRunning(string processname)
{
return Process.GetProcessesByName(processname).Length > 0;
}

private void button1_Click(object sender, EventArgs e)
{
string Connector;
string GameServer;
string Helper;
string LoginServer;
string Messenger;
bool ProcessRunning;
Connector = @"Server\\Connector\\Connector.exe";
GameServer = @"Server\\GameServer\\GameServer.exe";
Helper = @"Server\\Helper\\Helper.exe";
LoginServer = @"Server\\LoginServer\\LoginServer.exe";
Messenger = @"Server\\Messenger\\Messenger.exe";

if (File.Exists(Connector))
{
Process.Start(Connector);
}
else
{
MessageBox.Show("Konnte Connector nicht finden");
}
if (File.Exists(GameServer))
{
Process.Start(GameServer);
}
else
{
MessageBox.Show("Konnte GameServer nicht finden");
}
if (File.Exists(Helper))
{
Process.Start(Helper);
}
else
{
MessageBox.Show("Konnte Helper nicht finden");
}
if (File.Exists(LoginServer))
{
Process.Start(LoginServer);
}
else
{
MessageBox.Show("Konnte LoginServer nicht finden");
}
if (File.Exists(Messenger))
{
Process.Start(Messenger);
}
else
{
MessageBox.Show("Konnte Messenger nicht finden");
}

ProcessRunning = CheckIfAProcessIsRunning("connector");

while (ProcessRunning == false)
{
Process.Start(Connector);

}
}

private void Form1_Load(object sender, EventArgs e)
{

}
}
}[/Code]

 

Btw is here no spoiler?



Messages In This Thread
[No subject] - by Nikolee - 04-27-2012, 09:50 PM
[No subject] - by Nikolee - 04-27-2012, 10:20 PM
[No subject] - by HateMe - 04-28-2012, 12:03 PM
[No subject] - by Nikolee - 04-28-2012, 01:07 PM
[No subject] - by HateMe - 04-28-2012, 01:28 PM
[No subject] - by Nikolee - 04-28-2012, 04:36 PM
[No subject] - by Nikolee - 04-28-2012, 07:55 PM
[No subject] - by HateMe - 04-28-2012, 10:38 PM
[No subject] - by Nikolee - 05-01-2012, 10:09 PM
[No subject] - by HateMe - 05-01-2012, 11:06 PM
[No subject] - by Nikolee - 05-02-2012, 10:54 AM
[No subject] - by Nikolee - 05-03-2012, 01:24 PM
[No subject] - by someone - 05-03-2012, 11:35 PM
[No subject] - by HateMe - 05-04-2012, 12:00 AM
[No subject] - by Nikolee - 05-05-2012, 11:47 AM
[No subject] - by someone - 05-05-2012, 12:26 PM
[No subject] - by HateMe - 05-05-2012, 12:30 PM
[No subject] - by Nikolee - 05-05-2012, 12:37 PM
[No subject] - by HateMe - 05-05-2012, 01:11 PM
[No subject] - by Nikolee - 05-05-2012, 10:57 PM
[No subject] - by someone - 05-05-2012, 11:37 PM
[No subject] - by Nikolee - 05-06-2012, 04:09 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)