C# Restarter Source

Results 1 to 14 of 14
  1. #1
    Member Stroumpf is offline
    MemberRank
    Aug 2010 Join Date
    61Posts

    C# Restarter Source

    Tired of crash ?
    Use this, it will restart your server automaticly after the crash !


    Code:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Diagnostics;
    using System.IO;
    
    namespace Restarter
    {
        class Program
        {
            public static bool IsProcessRunning(string ProcessName, string Path)
            {
                foreach (Process clsProcess in Process.GetProcesses())
                {
                    if (clsProcess.ProcessName.Contains(ProcessName))
                    {
                        Console.WriteLine(ProcessName + " is still running!");
                        return true;
                    }
                }
                Console.WriteLine(ProcessName + " is not running anymore!");
                try
                {
                    Process.Start(Path);
                    Console.WriteLine("Starting the process. If no error pops up, it went all fine.");
                }
                catch
                {
                    Console.WriteLine(Path + " has NOT been executed. Please check if the path given exists.");
                }
                return false;
            }
    
            static void Main(string[] args)
            {
                Console.WriteLine("Copyright 2010 - DarKGunZ");
                Console.WriteLine("Stroumpf - All rights reserved");
    
                while (true)
                {
                    IsProcessRunning("Locator", "C:/Gunz/Locator/Locator.exe");
                    IsProcessRunning("MatchServer", "C:/Gunz/MatchServer/MatchServer.exe");
                    IsProcessRunning("MatchAgent", "C:/Gunz/MatchAgent/MatchAgent.exe");
                    System.Threading.Thread.Sleep(10000);
                }
            }
        }
    }
    Last edited by Stroumpf; 27-08-10 at 10:15 AM.


  2. #2
    Member Physix is offline
    MemberRank
    Aug 2010 Join Date
    51Posts

    Re: C# Restarter Source

    wow epic:O

    how i use XD

  3. #3
    Member Stroumpf is offline
    MemberRank
    Aug 2010 Join Date
    61Posts

    Re: C# Restarter Source

    Just open Visual Studio and make a C# Application put that in the code and compile.

    EDIT: Oh and edit the directory of your Locator/MatchServer/MatchAgent

  4. #4
    igunz.net Dawson is offline
    LegendRank
    Feb 2010 Join Date
    ::1 (Canada BC)Location
    2,581Posts

    Re: C# Restarter Source

    A .bat file works fine for a restarter but thanks for your efforts none the less.

  5. #5
    Member Stroumpf is offline
    MemberRank
    Aug 2010 Join Date
    61Posts

    Re: C# Restarter Source

    Quote Originally Posted by DawsonByrd View Post
    A .bat file works fine for a restarter but thanks for your efforts none the less.
    Yea a batch file will do the job

  6. #6
    Proficient Member steven1234 is offline
    MemberRank
    Jan 2010 Join Date
    186Posts

    Re: C# Restarter Source

    wow this is fail im bored ill code a better one

  7. #7
    Member Stroumpf is offline
    MemberRank
    Aug 2010 Join Date
    61Posts

    Re: C# Restarter Source

    Quote Originally Posted by steven1234 View Post
    wow this is fail im bored ill code a better one
    If it do the job, what is the fail here ?

  8. #8
    Proficient Member steven1234 is offline
    MemberRank
    Jan 2010 Join Date
    186Posts

    Re: C# Restarter Source

    if your gonna make a server keeper you got to make it better then the serverkeeper from maiet whats the point of having this when they can have that im currently coding one like it its like 80% done i needa test it out and all

  9. #9
    Member Stroumpf is offline
    MemberRank
    Aug 2010 Join Date
    61Posts

    Re: C# Restarter Source

    Quote Originally Posted by steven1234 View Post
    if your gonna make a server keeper you got to make it better then the serverkeeper from maiet whats the point of having this when they can have that im currently coding one like it its like 80% done i needa test it out and all
    Good luck on your project, I released what I use for DG and it work fine if you don't want to use it, don't use it and if you want to make a beter one, go ahead and good luck

  10. #10
    I am THE DON Joe9099 is offline
    MemberRank
    Jan 2007 Join Date
    England, UkLocation
    3,655Posts

    Re: C# Restarter Source

    I dont know why u dont use a bat tbh, its less of a memory hogger.
    Nice release but still there are plenty of these released ;o

  11. #11
    Just Me iceman4154 is offline
    MemberRank
    Oct 2007 Join Date
    Columbus, OhioLocation
    217Posts

    Re: C# Restarter Source

    lmao, since everyone is jumping on that train, I will make one in native C that uses a command prompt and uses .bat files to carryout the procedures. :P

  12. #12
    Proficient Member steven1234 is offline
    MemberRank
    Jan 2010 Join Date
    186Posts

    Re: C# Restarter Source

    ill do better mwhaha
    but then again itll be in c# cba to do in c++ c# is easyer to me

  13. #13
    Proficient Member taurias is offline
    MemberRank
    Dec 2008 Join Date
    178Posts

    Re: C# Restarter Source

    just do .bat...

    Code:
    @echo off
    set tempfile=bdw.txt
    :BEGIN
    TIMEOUT 10
    del %tempfile%
    tasklist > %tempfile%
    type %tempfile% | find /i "cmd.exe"
    if errorlevel 0 if not errorlevel 1 goto IsRunning
    start "PROGRAMNAME" "INSERT PATH HERE"
    GOTO BEGIN
    
    del %tempfile%
    exit
    
    :IsRunning
    taskkill.exe /f /fi "status eq not responding"
    echo IsRunning
    GOTO BEGIN
    also kills process if it goes not responding and restartes it.
    Last edited by taurias; 27-08-10 at 03:09 PM.

  14. #14
    Just Me iceman4154 is offline
    MemberRank
    Oct 2007 Join Date
    Columbus, OhioLocation
    217Posts

    Re: C# Restarter Source

    No you won't MUAHAHAHAHAHAHAHA.
    C vs. C#

    ROUND 1

    FIGHT!



Advertisement