Пример #1
0
 private void shutdown(string seconds)
 {
     ProcessManagement.LaunchCommandLineApp("cmd.exe", "/c shutdown -s -t " + seconds);
     lbOutput.Items.Add("Shutdown will occur in: " + seconds + " seconds.");
     btnAbortShutdown.Visibility = Visibility.Visible;
 }
Пример #2
0
 private void btnAbortShutdown_Click(object sender, RoutedEventArgs e)
 {
     ProcessManagement.LaunchCommandLineApp("cmd.exe", "/c shutdown -a");
     lbOutput.Items.Add("Shutdown aborted!");
     btnAbortShutdown.Visibility = Visibility.Hidden;
 }
Пример #3
0
        private bool ParseCommand(string cmd)
        {
            if (cmd == "abort")
            {
                if (ProcessManagement.StopProcess())
                {
                    isRunning = false;
                    return(true);
                }
                return(false);
            }
            else
            {
                if (commands == null)
                {
                    commands = LoadCmds.load("/commands/cmd");
                }
                string[] cmdParameters = cmd.Split('-');
                int      cmdNr         = -1;
                for (int i = 0; i < commands.Count; i++)
                {
                    if (cmdParameters[0] == commands[i])
                    {
                        cmdNr = i;
                        break;
                    }
                }

                if (!isRunning)
                {
                    switch (cmdNr)
                    {
                    case 0:
                    {
                        if (!ProcessManagement.LaunchCommandLineApp(DEFRAG_DISK_CMD, cmdParameters[1]))
                        {
                            return(false);
                        }
                        else
                        {
                            isRunning = true;
                        }
                    }
                    break;

                    case 1:
                    {
                        string arg = CHECK_DISK_PARAMS + cmdParameters[1] + CHECK_DISK_ARG;
                        if (!ProcessManagement.LaunchCommandLineApp(CHECK_DISK_CMD, arg))
                        {
                            return(false);
                        }
                        else
                        {
                            isRunning = true;
                        }
                    }
                    break;

                    case 2:
                        if (!ProcessManagement.LaunchCommandLineApp(CLEANER_DISK_CMD, CLEANER_DISK_PARAMS + cmdParameters[1]))
                        {
                            return(false);
                        }
                        break;

                    case 3:
                        if (!ProcessManagement.LaunchCommandLineApp("ssDownload.bat", "", arguments2: "1"))
                        {
                            return(false);
                        }
                        break;

                    case 4:
                        if (SendMail(cmdParameters[1], cmdParameters[2], cmdParameters[3]))
                        {
                            lbOutput.Items.Add("Mail Send to: " + cmdParameters[1]);
                            lbOutput.Items.Add("Subject: " + cmdParameters[2]);
                            lbOutput.Items.Add("Body: " + cmdParameters[3]);
                        }
                        else
                        {
                            return(false);
                        }
                        break;

                    case 5:
                        int seconds = 0;
                        if (int.TryParse(cmdParameters[1], out seconds))
                        {
                            shutdown(cmdParameters[1]);
                            return(true);
                        }
                        return(false);

                    case 6:
                        this.WindowState = WindowState.Minimized;
                        break;

                    case 7:
                        string[] about = LoadCmds.load("/commands/about")[0].Split(';');
                        foreach (string s in about)
                        {
                            lbOutput.Items.Add(s);
                        }
                        break;

                    case 8:
                        string[] help = LoadCmds.load("/commands/help")[0].Split(';');
                        foreach (string s in help)
                        {
                            lbOutput.Items.Add(s);
                        }
                        break;

                    case 9:
                        this.Close();
                        break;

                    default:
                        return(false);
                    }
                }

                return(true);
            }
        }