static void Main(string[] args) { CommandLineArgs ARGH = new CommandLineArgs(); ARGH.IgnoreCase = true; ARGH.PrefixRegexPatternList.Add("/{1}"); ARGH.PrefixRegexPatternList.Add("-{1,2}"); ARGH.ProcessCommandLineArgs(args); //Argument processing: // We need arguments for the following: // 1: -IP // 2: -Port // 3: -Verbose // -endpoint net.tcp://10.160.147.48:8383/TaskConsole/ -verbose string myendpoint = @"net.tcp://" + ARGH["ip"] + ":" + ARGH["port"] + @"/StivTaskConsole/"; string path; path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase); GV.Exedir = path.Remove(0, 6) + @"\"; GV.LogFile = path.Remove(0, 6) + @"\_StivAgent.log"; if (File.Exists(GV.LogFile)) { File.Delete(GV.LogFile); } GV.CurrentActionForLog = "Starting up! Connecting unto " + myendpoint; NetTcpBinding bindbert = new NetTcpBinding(); bindbert.Security.Mode = SecurityMode.None; GV.ConsoleContract = new ChannelFactory <TaskConsoleWCFService.ContractDefinition>(bindbert); GV.ConsoleEndPoint = myendpoint; if (ARGH.ContainsSwitch("verbose")) { GV.Verbose = true; } else { GV.Verbose = false; } //This agent handles system requests from the Task Console. //Options -StopServices [servicelist] -StartServices [servicelist] -RestartServices [servicelist] -Restart -CheckWSUSUpdates -IISRESET -IISSTOP -IISSTART -InstallUpdates // -AddUsers [Userlist] -AddAdmins [UserList] -DisableUsers [Userlist] -EnableUsers [Userlist] // -Terminate //http://www.nullskull.com/a/1592/install-windows-updates-using-c--wuapi.aspx ThreadClass TC = new ThreadClass(); Thread WhackerThread = new Thread(new ThreadStart(TC.Whacker)) { IsBackground = true }; WhackerThread.Start(); Thread ListenThread = new Thread(new ThreadStart(TC.Listener)) { IsBackground = true }; ListenThread.Start(); Thread.Sleep(System.Threading.Timeout.Infinite); }