public void Run()
        {
            if (File.Exists(connection.GetEffectiveAppPath()))
            {
                string host = connection.Parameters.First(p => p.Name == KnownParameters.Host).Value;
                string port = connection.Parameters.First(p => p.Name == KnownParameters.Port).Value;

                using (Process puttyProcess = new Process())
                {
                    puttyProcess.StartInfo.FileName  = connection.GetEffectiveAppPath();
                    puttyProcess.StartInfo.Arguments = " -telnet ";

                    string username = connection.Parameters.First(p => p.Name == KnownParameters.User).Value;
                    string password = connection.Parameters.First(p => p.Name == KnownParameters.Password).Value;

                    puttyProcess.StartInfo.Arguments += !string.IsNullOrEmpty(username) ? username + "@" : "";

                    puttyProcess.StartInfo.Arguments += !string.IsNullOrEmpty(host) ? host : "";
                    puttyProcess.StartInfo.Arguments += !string.IsNullOrEmpty(port) ? " " + port : "";

                    puttyProcess.Start();

                    Thread.Sleep(1500);

                    IntPtr h = puttyProcess.MainWindowHandle;

                    SetForegroundWindow(h);
                    SendKeys.SendWait(username);
                    SendKeys.SendWait("~");
                    SendKeys.SendWait(password);
                    SendKeys.SendWait("~");
                }
            }
        }
        public void Run()
        {
            if (File.Exists(_connection.GetEffectiveAppPath()))
            {
                var hostParam = _connection.Parameters.First(p => p.Name == KnownParameters.Host);
                var portParam = _connection.Parameters.First(p => p.Name == KnownParameters.Port);


                var vncFilePath     = OtherHelper.ReplaceU(f, _connection.Name) + ".vnc";
                var vncOutPathParam = _connection.Parameters.First(p => p.Name == "OutputFolder");
                if (vncOutPathParam != null && !string.IsNullOrEmpty(vncOutPathParam.Value))
                {
                    Directory.CreateDirectory(vncOutPathParam.Value);
                    vncFilePath = Path.Combine(vncOutPathParam.Value, vncFilePath);
                }
                TextWriter vncFile = new StreamWriter(vncFilePath);

                vncFile.WriteLine("[Connection]");
                vncFile.WriteLine(hostParam.GetCommandLine());
                vncFile.WriteLine(portParam.GetCommandLine());

                var userParam = _connection.Parameters.First(p => p.Name == KnownParameters.User);
                vncFile.WriteLine(userParam.GetCommandLine());
                var passParam = _connection.Parameters.First(p => p.Name == KnownParameters.Password);
                vncFile.WriteLine(passParam.GetCommandLine());

                vncFile.WriteLine("[Options]");
                var fullScreenParam = _connection.Parameters.First(p => p.Name == "IsFullScreen");
                vncFile.WriteLine(fullScreenParam.GetCommandLine());

                var viewOnly = _connection.Parameters.First(p => p.Name == "ViewOnly");
                vncFile.WriteLine(viewOnly.GetCommandLine());

                vncFile.WriteLine(passParam.Value != "" && passParam.Value.Length > 8 ? "protocol3.3=1" : ""); // f****n vnc 4.0 auth

                vncFile.Close();

                Process myProc = new Process
                {
                    StartInfo =
                    {
                        FileName  = _connection.GetEffectiveAppPath(),
                        Arguments = "-config \"" + vncFilePath
                    }
                };

                myProc.Start();
            }
        }
Exemple #3
0
        public void Run()
        {
            string rdpPath = Environment.ExpandEnvironmentVariables(_connection.GetEffectiveAppPath());

            if (File.Exists(rdpPath))
            {
                var parameters = _connection.Parameters.Where(p => p.DisplayName != "Размер экрана").ToList();

                var outputFile        = OtherHelper.ReplaceU(f, _connection.Name) + ".rdp";
                var outputFolderParam = _connection.Parameters.FirstOrDefault(p => p.Name == "OutputFolder");
                if (outputFolderParam != null && !string.IsNullOrEmpty(outputFolderParam.Value))
                {
                    Directory.CreateDirectory(outputFolderParam.Value);
                    outputFile = Path.Combine(outputFolderParam.Value, outputFile);
                }

                TextWriter rdpFileWriter = new StreamWriter(path: outputFile);

                foreach (var p in parameters.Where(p => !(p is FolderPathConnectionParameter)))
                {
                    var line = p.GetCommandLine();
                    if (string.IsNullOrEmpty(line))
                    {
                        continue;
                    }
                    rdpFileWriter.Write(line);
                    var delimiter = p.NextParameterDelimiter ?? _connection.ParameterDelimiter;
                    rdpFileWriter.Write(delimiter);
                }

                var fullScreen = _connection.Parameters.FirstOrDefault(p => p.Name == "IsFullScreen") as SwitchConnectionParameter;
                if (fullScreen != null && !fullScreen.IsOn)
                {
                    var      size  = _connection.Parameters.FirstOrDefault(p => p.Name == "ScreenSize").Value;
                    string[] sizes = size.Split('x');

                    rdpFileWriter.WriteLine(sizes.Length == 2 ? "desktopwidth:i:" + sizes[0] : "");
                    rdpFileWriter.WriteLine(sizes.Length == 2 ? "desktopheight:i:" + sizes[1] : "");
                }

                rdpFileWriter.Close();

                Process myProc = new Process
                {
                    StartInfo =
                    {
                        FileName  = rdpPath,
                        Arguments = $"\"{outputFile}\"",
                    }
                };

                myProc.Start();
            }
        }
Exemple #4
0
        public void Run()
        {
            if (!File.Exists(_connection.GetEffectiveAppPath()))
            {
                return;
            }

            var generator = _cmdLineGeneratorFactory(_connection);

            var args = string.Format("/C {0}", generator.GetCommandLine());

            Process.Start("CMD.exe", args);
        }
        public void Run()
        {
            var appPath = _connection.GetEffectiveAppPath();

            if (!File.Exists(appPath))
            {
                return;
            }

            var generator = _cmdLineGeneratorFactory(_connection);

            var args = generator.GetArgumentsLine();

            Process.Start(appPath, args);
        }