問題は主に Read() メソッドにあります。
public static void Read(object source, ElapsedEventArgs e)
{
serverID = File.ReadAllText(sidname);
Console.WriteLine("Current ID: " + serverID);
if (serverID != oldserverID && serverID != "default" && serverID != "")
{
ProcessStartInfo servqueued = new ProcessStartInfo();
servqueued.Arguments = ramlimit + " " + spname + " " + sidname + " " + resourcetxt + " " + ramoutput + " " + rootpath + Path.DirectorySeparatorChar + " " + makeserverpath + " " + Logpath + " " + servqueuepath;
servqueued.FileName = fileservepath;
servqueued.WindowStyle = ProcessWindowStyle.Normal;
servqueued.CreateNoWindow = false;
Process queue;
queue = Process.Start(servqueued);
Console.WriteLine("Server process queued with server name: " + serverID);
File.AppendAllLines(logpath, new string[] { DateTime.Now.ToString("HH:mm:ss tt") + ": ", "Server process queued with server name " + serverID });
oldserverID = serverID;
}
}
Process.Start が無視される理由がわかりません。句の残りの部分は問題ありません。たとえば、最初に oldserverID を配置した場合などです。
編集
引数はグローバル変数であり、スクリプトの前半で定義されています。
編集
参照されるグローバル変数は次のとおりです。パスのハードコーディングに注意してください。
rootpath = "%USERPROFILE%" + Path.DirectorySeparatorChar +"desktop" + Path.DirectorySeparatorChar + "TerrariaServer" + Path.DirectorySeparatorChar + "filebin";
logpath = rootpath + Path.DirectorySeparatorChar + "fr_log.txt";
servqueuepath = rootpath + Path.DirectorySeparatorChar + "queuecheck.txt";
spname = "serverparams.cmd";
sidname = "serverid.cmd";
resourcetxt = rootpath + Path.DirectorySeparatorChar + "ramcheck.txt";
ramoutput = rootpath + Path.DirectorySeparatorChar + "sysresourceoutput.exe";
makeserverpath = rootpath + Path.DirectorySeparatorChar + "update.bat";
Logpath = rootpath + Path.DirectorySeparatorChar + "fsrv_log.txt";
fileservepath = rootpath + Path.DirectorySeparatorChar + "FileServe.exe";
アップデート
適切なデバッグ方法 (以下) を使用することで、問題の原因が.. 解決され、タイトルが編集されました。