public void Handle(string[] commands, IiControlClient client)
        {
            string path = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "commandlog.txt");
            string text = String.Format("[{0:s}] [{1,15}] >> {2}", System.DateTime.Now, client.IPAddress, String.Join(" ", commands)) + Environment.NewLine;

            System.IO.File.AppendAllText(path, text);
        }
Пример #2
0
        public void Handle(string[] commands, IiControlClient client)
        {
            if (commands[0] == "pwrmngmt")
            {
                switch (commands[1])
                {
                case "shutdown":
                    pluginHost.Log("Shutting down", this);
                    System.Diagnostics.Process.Start("shutdown.exe", "-s -f -t 0");
                    break;

                case "restart":
                    pluginHost.Log("Restarting", this);
                    System.Diagnostics.Process.Start("shutdown.exe", "-r -f -t 0");
                    break;

                case "logoff":
                    pluginHost.Log("Logging of the current user", this);
                    System.Diagnostics.Process.Start("shutdown.exe", "-l -f -t 0");
                    break;

                case "lock":
                    pluginHost.Log("Lock workstation", this);
                    LockWorkStation();
                    break;

                case "hibernate":
                    pluginHost.Log("Hibernating", this);
                    System.Windows.Forms.Application.SetSuspendState(System.Windows.Forms.PowerState.Hibernate, true, true);
                    break;

                case "standby":
                    pluginHost.Log("Going to stand by", this);
                    System.Windows.Forms.Application.SetSuspendState(System.Windows.Forms.PowerState.Suspend, true, true);
                    break;

                default:
                    break;
                }
            }
        }
        public void Handle(string[] commands, IiControlClient client)
        {
            if (commands[0] == "launch")
            {
                NetworkStream clientStream = client.TCP.GetStream();
                ASCIIEncoding encoder      = new ASCIIEncoding();
                foreach (string file in System.IO.Directory.GetFiles(_execpath))
                {
                    System.IO.FileInfo fi = new System.IO.FileInfo(file);

                    if (System.IO.Path.GetFileNameWithoutExtension(file).Equals(commands[1]) || System.IO.Path.GetFileName(file).Equals(commands[1]))
                    {
                        System.Diagnostics.Process.Start(file, String.Join(" ", commands, 2, commands.Length - 2));
                        Host.Log("Launched " + file, this);
                        byte[] buffer = encoder.GetBytes("Launched " + file);
                        clientStream.Write(buffer, 0, buffer.Length);
                        clientStream.Flush();
                    }
                }
            }
        }