Index: misc/tools/HeuristicLab.HiveDrain/HiveStatus/Program.cs
===================================================================
--- misc/tools/HeuristicLab.HiveDrain/HiveStatus/Program.cs	(revision 15921)
+++ misc/tools/HeuristicLab.HiveDrain/HiveStatus/Program.cs	(revision 16667)
@@ -31,9 +31,9 @@
     public const int EXIT_OK = 0;
     public const int EXIT_ERR = 1;
-    public const int EXIT_WAITING = 2;
-    public const int EXIT_FAILED = 3;
-    public const int EXIT_NOTFOUND = 4;
+    public const int EXIT_FAILED = 2;
+    public const int EXIT_NOTFOUND = 3;
 
     static void Main(string[] args) {
+      //AppDomain.CurrentDomain.SetData("APP_CONFIG_FILE", "HiveStatus.exe.config");
       var result = Parser.Default.ParseArguments<Options>(args)
         .WithParsed(x => {
@@ -45,15 +45,137 @@
     }
 
-    private static int Run(Options opt) {
-      if (!string.IsNullOrEmpty(opt.Username)) {
-        HiveServiceLocator.Instance.Username = opt.Username;
-        var password = opt.Password;
+    private static int Run(Options opts) {
+#if __DRY_RUN__
+      Console.WriteLine("DONE");
+      return EXIT_OK;
+#endif
+      if (string.IsNullOrEmpty(opts.Username) && HeuristicLab.Clients.Common.Properties.Settings.Default.UserName.ToLower() == "anonymous") {
+        Console.Write("Username: ");
+        opts.Username = Console.ReadLine();
+      }
+      if (!string.IsNullOrEmpty(opts.Username)) {
+        HiveServiceLocator.Instance.Username = opts.Username;
+        var password = opts.Password;
         if (string.IsNullOrEmpty(password)) {
-          Console.Error.Write("Password for " + opt.Username + ": ");
+          Console.Error.Write("Password for " + opts.Username + ": ");
           password = ReadPassword();
         }
         HiveServiceLocator.Instance.Password = password;
       }
-      return CheckStatus(opt);
+      return CheckStatus(opts);
+    }
+
+    private static int CheckStatus(Options opt) {
+      if (opt.JobId == default(Guid)) return CheckStatusAll(opt);
+
+      var jobId = opt.JobId;
+
+      if (opt.Verbose) {
+
+        List<LightweightTask> tasks = null;
+        try {
+          tasks = HiveServiceLocator.Instance.CallHiveService(x => x.GetLightweightJobTasksWithoutStateLog(jobId));
+        } catch (System.ServiceModel.Security.SecurityAccessDeniedException) {
+          Console.WriteLine("?");
+          return EXIT_NOTFOUND;
+        }
+
+        int completed, failed, running, paused;
+        GetStats(tasks, out completed, out failed, out running, out paused);
+        Console.WriteLine(FormatStateInfo(tasks.Count, completed, failed, running, paused));
+        return failed > 0 ? EXIT_FAILED : EXIT_OK;
+
+      } else {
+
+        Job job = null;
+        try {
+          job = HiveServiceLocator.Instance.CallHiveService(x => x.GetJob(jobId));
+        } catch (System.ServiceModel.Security.SecurityAccessDeniedException) {
+          Console.WriteLine("?");
+          return EXIT_NOTFOUND;
+        }
+        Console.WriteLine(FormatStateInfo(job.JobCount, job.FinishedCount, job.CalculatingCount));
+        return EXIT_OK;
+      }
+    }
+
+    private static int CheckStatusAll(Options opt) {
+      List<Job> jobs = null;
+      try {
+        jobs = HiveServiceLocator.Instance.CallHiveService(x => x.GetJobs());
+      } catch (System.ServiceModel.Security.SecurityAccessDeniedException) {
+        Console.WriteLine("?");
+        return EXIT_NOTFOUND;
+      }
+
+      if (opt.Verbose) {
+        List<LightweightTask> tasks = null;
+        int totFinished, totFailed, totCalculating, totPaused, total;
+        totFinished = totFailed = totCalculating = totPaused = total = 0;
+        try {
+
+          foreach (var j in jobs) {
+            tasks = HiveServiceLocator.Instance.CallHiveService(x => x.GetLightweightJobTasksWithoutStateLog(j.Id));
+
+            int finished, failed, calculating, paused;
+            GetStats(tasks, out finished, out failed, out calculating, out paused);
+            totFinished += finished;
+            totFailed += failed;
+            totCalculating += calculating;
+            totPaused += paused;
+            total += tasks.Count;
+
+            Console.WriteLine(FormatStateInfo(tasks.Count, finished, failed, calculating, paused) + " | " + Truncate(j.Name, 40).PadRight(40) + " | " + j.DateCreated.ToShortDateString());
+          }
+        } catch (System.ServiceModel.Security.SecurityAccessDeniedException) {
+          Console.WriteLine("?");
+          return EXIT_NOTFOUND;
+        }
+        Console.WriteLine();
+        Console.WriteLine(FormatStateInfo(total, totFinished, totFailed, totCalculating, totPaused) + " | ALL");
+        return totFailed > 0 ? EXIT_FAILED : EXIT_OK;
+      } else {
+        int totFinished, totCalculating, total;
+        totFinished = totCalculating = total = 0;
+        foreach (var j in jobs) {
+          Console.WriteLine(FormatStateInfo(j.JobCount, j.FinishedCount, j.CalculatingCount) + " | " + Truncate(j.Name, 40).PadRight(40) + " | " + j.DateCreated.ToShortDateString());
+          totFinished += j.FinishedCount;
+          totCalculating += j.CalculatingCount;
+          total += j.JobCount;
+        }
+        Console.WriteLine();
+        Console.WriteLine(FormatStateInfo(total, totFinished, totCalculating) + " | ALL");
+        return EXIT_OK;
+      }
+    }
+
+    private static void GetStats(List<LightweightTask> tasks, out int completed, out int failed, out int running, out int paused) {
+      completed = tasks.Count(x => x.State == TaskState.Finished);
+      failed = tasks.Count(x => x.State == TaskState.Failed || x.State == TaskState.Aborted);
+      running = tasks.Count(x => x.State == TaskState.Calculating || x.State == TaskState.Transferring
+|| x.State == TaskState.Waiting);
+      paused = tasks.Count(x => x.State == TaskState.Paused);
+    }
+
+    private static string FormatStateInfo(int total, int finished, int calculating) {
+      var state = finished == total ? "DONE" : "CALC";
+      return string.Join(" ", new object[] { state
+        , "CALC=" + calculating.ToString().PadRight(4)
+        , "DONE=" + finished.ToString().PadRight(4) });
+    }
+
+    private static string FormatStateInfo(int total, int finished, int failed, int calculating, int paused) {
+      var state = finished == total ? "DONE" : failed > 0 ? "FAIL" : calculating > 0 ? "CALC" : paused > 0 ? "PAUS" : "NDEF";
+      return string.Join(" ", new object[] { state
+        , "CALC=" + calculating.ToString().PadRight(4)
+        , "DONE=" + finished.ToString().PadRight(4)
+        , "FAIL=" + failed.ToString().PadRight(4)
+        , "PAUS=" + paused.ToString().PadRight(4) });
+    }
+
+    #region Helpers
+    private static string Truncate(string text, int length) {
+      if (text.Length <= length) return text;
+      return text.Substring(0, length - 3) + "...";
     }
 
@@ -103,117 +225,5 @@
       return sb.ToString();
     }
-
-    private static int CheckStatus(Options opt) {
-      if (opt.All) return CheckStatusAll(opt);
-
-      var jobId = opt.JobId;
-
-      if (opt.Verbose) {
-
-        List<LightweightTask> tasks = null;
-        try {
-          tasks = HiveServiceLocator.Instance.CallHiveService(x => x.GetLightweightJobTasksWithoutStateLog(jobId));
-        } catch (System.ServiceModel.Security.SecurityAccessDeniedException) {
-          Console.WriteLine("?");
-          return EXIT_NOTFOUND;
-        }
-
-        int completed, failed, running, paused;
-        GetStats(tasks, out completed, out failed, out running, out paused);
-        Console.WriteLine(FormatStateInfo(tasks.Count, completed, failed, running, paused));
-        return completed == tasks.Count ? EXIT_OK : failed > 0 ? EXIT_FAILED : EXIT_WAITING;
-
-      } else {
-
-        Job job = null;
-        try {
-          job = HiveServiceLocator.Instance.CallHiveService(x => x.GetJob(jobId));
-        } catch (System.ServiceModel.Security.SecurityAccessDeniedException) {
-          Console.WriteLine("?");
-          return EXIT_NOTFOUND;
-        }
-        Console.WriteLine(FormatStateInfo(job.JobCount, job.FinishedCount, job.CalculatingCount));
-        return job.FinishedCount == job.JobCount ? EXIT_OK : EXIT_WAITING;
-      }
-    }
-
-    private static int CheckStatusAll(Options opt) {
-      List<Job> jobs = null;
-      try {
-        jobs = HiveServiceLocator.Instance.CallHiveService(x => x.GetJobs());
-      } catch (System.ServiceModel.Security.SecurityAccessDeniedException) {
-        Console.WriteLine("?");
-        return EXIT_NOTFOUND;
-      }
-
-      if (opt.Verbose) {
-        List<LightweightTask> tasks = null;
-        int totFinished, totFailed, totCalculating, totPaused, total;
-        totFinished = totFailed = totCalculating = totPaused = total = 0;
-        try {
-
-          foreach (var j in jobs) {
-            tasks = HiveServiceLocator.Instance.CallHiveService(x => x.GetLightweightJobTasksWithoutStateLog(j.Id));
-
-            int finished, failed, calculating, paused;
-            GetStats(tasks, out finished, out failed, out calculating, out paused);
-            totFinished += finished;
-            totFailed += failed;
-            totCalculating += calculating;
-            totPaused += paused;
-            total += tasks.Count;
-
-            Console.WriteLine(FormatStateInfo(tasks.Count, finished, failed, calculating, paused) + " | " + Truncate(j.Name, 40).PadRight(40) + " | " + j.DateCreated.ToShortDateString());
-          }
-        } catch (System.ServiceModel.Security.SecurityAccessDeniedException) {
-          Console.WriteLine("?");
-          return EXIT_NOTFOUND;
-        }
-        Console.WriteLine();
-        Console.WriteLine(FormatStateInfo(total, totFinished, totFailed, totCalculating, totPaused) + " | ALL");
-        return totFinished == total ? EXIT_OK : totFailed > 0 ? EXIT_FAILED : EXIT_WAITING;
-      } else {
-        int totFinished, totCalculating, total;
-        totFinished = totCalculating = total = 0;
-        foreach (var j in jobs) {
-          Console.WriteLine(FormatStateInfo(j.JobCount, j.FinishedCount, j.CalculatingCount) + " | " + Truncate(j.Name, 40).PadRight(40) + " | " + j.DateCreated.ToShortDateString());
-          totFinished += j.FinishedCount;
-          totCalculating += j.CalculatingCount;
-          total += j.JobCount;
-        }
-        Console.WriteLine();
-        Console.WriteLine(FormatStateInfo(total, totFinished, totCalculating) + " | ALL");
-        return totFinished == total ? EXIT_OK : EXIT_WAITING;
-      }
-    }
-
-    private static void GetStats(List<LightweightTask> tasks, out int completed, out int failed, out int running, out int paused) {
-      completed = tasks.Count(x => x.State == TaskState.Finished);
-      failed = tasks.Count(x => x.State == TaskState.Failed || x.State == TaskState.Aborted);
-      running = tasks.Count(x => x.State == TaskState.Calculating || x.State == TaskState.Transferring
-|| x.State == TaskState.Waiting);
-      paused = tasks.Count(x => x.State == TaskState.Paused);
-    }
-
-    private static string FormatStateInfo(int total, int finished, int calculating) {
-      var state = finished == total ? "DONE" : "CALC";
-      return string.Join(" ", new object[] { state
-        , "CALC=" + calculating.ToString().PadRight(4)
-        , "DONE=" + finished.ToString().PadRight(4) });
-    }
-
-    private static string FormatStateInfo(int total, int finished, int failed, int calculating, int paused) {
-      var state = finished == total ? "DONE" : failed > 0 ? "FAIL" : calculating > 0 ? "CALC" : paused > 0 ? "PAUS" : "NDEF";
-      return string.Join(" ", new object[] { state
-        , "CALC=" + calculating.ToString().PadRight(4)
-        , "DONE=" + finished.ToString().PadRight(4)
-        , "FAIL=" + failed.ToString().PadRight(4)
-        , "PAUS=" + paused.ToString().PadRight(4) });
-    }
-
-    private static string Truncate(string text, int length) {
-      if (text.Length <= length) return text;
-      return text.Substring(0, length - 3) + "...";
-    }
+    #endregion
   }
 }
