diff --git a/.vs/RustAutoStarter/v16/.suo b/.vs/RustAutoStarter/v16/.suo
index 55777a5..e44f5dc 100644
Binary files a/.vs/RustAutoStarter/v16/.suo and b/.vs/RustAutoStarter/v16/.suo differ
diff --git a/Program.cs b/Program.cs
index 1532025..f5c425d 100644
--- a/Program.cs
+++ b/Program.cs
@@ -1,17 +1,43 @@
using System;
using System.Diagnostics;
+using System.IO;
using System.Threading;
-
namespace RustAutoStarter
{
class Program
{
static void Main(string[] args)
{
- while (true)
+ string startupfile = "CustomMap.bat"; //Sets default bat to run.
+ if (args.Length == 1) //Checks if args have been passed
+ startupfile = args[0]; //Sets passed args as the startup file to run.
+
+ //Check that starup bat exsists
+ Console.WriteLine("Searching for startup bat " + Environment.CurrentDirectory + @"\" + startupfile);
+ if (!File.Exists(Environment.CurrentDirectory + @"\" + startupfile))
{
- Process[] pname = Process.GetProcessesByName("RustDedicated");
- if (pname.Length == 0)
+ Console.WriteLine("Startup bat not found, If no args passed then default will be CustomMap.Bat");
+ Console.ReadKey();
+ Environment.Exit(0);
+ }
+ //Sets title of window to bat it will run.
+ Console.Title = Environment.CurrentDirectory + @"\" + startupfile;
+ while (true) //Makes it a constant loop
+ {
+ Process[] pname = Process.GetProcessesByName("RustDedicated"); //Gets all processes called RustDedicated
+ //Loops though incase hosting multipal servers.
+ bool found = false;
+ foreach (Process p in pname)
+ {
+ if (Environment.CurrentDirectory == p.MainModule.FileName.Replace("\\RustDedicated.exe",""))
+ {
+ //Found so break for loop.
+ found = true;
+ break;
+ }
+ }
+ //If not found then start up.
+ if (!found)
{
DateTime now = DateTime.Now;
Console.WriteLine("Rust server offline " + now);
@@ -21,7 +47,7 @@ namespace RustAutoStarter
{
proc = new Process();
proc.StartInfo.WorkingDirectory = Environment.CurrentDirectory;
- proc.StartInfo.FileName = "CustomMap.bat";
+ proc.StartInfo.FileName = startupfile;
proc.Start();
}
catch (Exception ex)
@@ -29,7 +55,7 @@ namespace RustAutoStarter
Console.WriteLine(ex.StackTrace.ToString());
}
}
- Thread.Sleep(10000);
+ Thread.Sleep(10000); //Sleep for 10 secs
}
}
}
diff --git a/RustAutoStarter.csproj b/RustAutoStarter.csproj
index 9f9477b..879be72 100644
--- a/RustAutoStarter.csproj
+++ b/RustAutoStarter.csproj
@@ -14,7 +14,7 @@
true
- AnyCPU
+ x64
true
full
false
diff --git a/bin/Debug/RustAutoStarter.exe b/bin/Debug/RustAutoStarter.exe
index e9bb803..d1d23e5 100644
Binary files a/bin/Debug/RustAutoStarter.exe and b/bin/Debug/RustAutoStarter.exe differ
diff --git a/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
index 7b875f8..b411833 100644
Binary files a/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache and b/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ
diff --git a/obj/Debug/RustAutoStarter.csprojAssemblyReference.cache b/obj/Debug/RustAutoStarter.csprojAssemblyReference.cache
index 24df8ab..684a438 100644
Binary files a/obj/Debug/RustAutoStarter.csprojAssemblyReference.cache and b/obj/Debug/RustAutoStarter.csprojAssemblyReference.cache differ
diff --git a/obj/Debug/RustAutoStarter.exe b/obj/Debug/RustAutoStarter.exe
index e9bb803..d1d23e5 100644
Binary files a/obj/Debug/RustAutoStarter.exe and b/obj/Debug/RustAutoStarter.exe differ
diff --git a/obj/Debug/RustAutoStarter.pdb b/obj/Debug/RustAutoStarter.pdb
index b05e8c0..f87607b 100644
Binary files a/obj/Debug/RustAutoStarter.pdb and b/obj/Debug/RustAutoStarter.pdb differ