public override void Do() { foreach (var folder in FoldersToOpen) { if (!FileSystemCommand.DirectoryExists(folder)) { DidCommandSucceed = false; SendReport($"Windows Explorer cannot open directory {folder} because it doesn't exist", ReportType.DoneTaskWithFailure); return; } if (CommandLineArguments.Any()) { CommandLineArguments[0] = $"/open, {folder}"; } else { CommandLineArguments.Add($"/open, {folder}"); } runCommand(); SendReport($"Windows Explorer exited with code {ExitCode} for directory {folder}", ReportType.Progress); } DidCommandSucceed = true; SendReport($"Windows Explorer opened all requested folders successfully", ReportType.DoneTaskWithSuccess); }
protected override void SetArguments() { CommandLineArguments.Add($"clone --branch {Branch}"); CommandLineArguments.Add(RemoteRepo); CommandLineArguments.Add($"\"{LocalCloneDirectory}\""); CommandLineArguments.Add("--recurse-submodules"); }
protected override void SetArguments() { CommandLineArguments.Add($"/nologo"); CommandLineArguments.Add($"\"{Source}\""); CommandLineArguments.Add($"/p:Configuration={Configuration}"); CommandLineArguments.Add($"/t:Clean,Build"); }
protected override void SetArguments() { CommandLineArguments.Add($"/nologo"); CommandLineArguments.Add($"\"{Source}\""); CommandLineArguments.Add($"/p:DeployOnBuild=true"); CommandLineArguments.Add($"/p:Configuration={Configuration}"); CommandLineArguments.Add($"/p:PublishProfile={PublishProfile}"); }
protected override void SetArguments() { var gitDir = getLocalRepoGitFile(); CommandLineArguments.Add($"--git-dir={gitDir}"); CommandLineArguments.Add("pull"); CommandLineArguments.Add(RemoteName); CommandLineArguments.Add(BranchName); }
public Task <bool> Start(OpenVpnProcessParams processParams) { var localIp = new BestLocalEndpoint(processParams.Endpoint).Ip(); var arguments = new CommandLineArguments() .Add(new BasicArguments(_config)) .Add(new ManagementArguments(_config, processParams.ManagementPort)) .Add(new EndpointArguments(processParams.Endpoint)) .Add(new BindArguments(localIp)) .Add(new CustomDnsArguments(processParams.CustomDns)) .Add(new TlsVerifyArguments(_config, processParams.Endpoint.Server.Name)); if (processParams.SplitTunnelMode == SplitTunnelMode.Permit) { arguments.Add(new LowDefaultRouteArgument()); } if (processParams.SplitTunnelMode != SplitTunnelMode.Disabled && processParams.SplitTunnelIPs.Count > 0) { arguments.Add(new SplitTunnelRoutesArgument( processParams.SplitTunnelIPs, processParams.SplitTunnelMode)); } _startCompletionSource?.TrySetCanceled(); _startCompletionSource = new TaskCompletionSource <bool>(); _process = _processes.Process(_config.ExePath, arguments); AddEventHandlers(); _process.Start(); _logger.Info("OpenVPN <- Management channel password"); _process.StandardInput.WriteLine(processParams.Password); return(_startCompletionSource.Task); }
private string GetCommandLineArguments(OpenVpnProcessParams processParams) { CommandLineArguments arguments = new CommandLineArguments() .Add(new BasicArguments(_config)) .Add(new ManagementArguments(_config, processParams.ManagementPort)) .Add(new OpenVpnEndpointArguments(processParams.Endpoint)) .Add(new BindArguments(new BestLocalOpenVpnEndpoint(processParams.Endpoint).Ip())) .Add(new CustomDnsArguments(processParams.CustomDns)) .Add(new TlsVerifyArguments(_config, processParams.Endpoint.Server.Name)) .Add(new BaseRouteArgument(processParams.SplitTunnelMode)) .Add(new SplitTunnelRoutesArgument(processParams.SplitTunnelIPs, processParams.SplitTunnelMode)); if (processParams.OpenVpnAdapter == OpenVpnAdapter.Tun) { arguments.Add(new NetworkDriverArgument(processParams.InterfaceGuid, processParams.OpenVpnAdapter)); } return(arguments); }
public override bool Connect() { try { _isPuttyNg = PuttyTypeDetector.GetPuttyType() == PuttyTypeDetector.PuttyType.PuttyNg; PuttyProcess = new Process { StartInfo = { UseShellExecute = false, FileName = PuttyPath } }; var arguments = new CommandLineArguments { EscapeForShell = false }; arguments.Add("-load", InterfaceControl.Info.PuttySession); if (!(InterfaceControl.Info is PuttySessionInfo)) { arguments.Add("-" + PuttyProtocol); if (PuttyProtocol == Putty_Protocol.ssh) { var username = ""; var password = ""; if (!string.IsNullOrEmpty(InterfaceControl.Info?.Username)) { username = InterfaceControl.Info.Username; } else { // ReSharper disable once SwitchStatementMissingSomeCases switch (Settings.Default.EmptyCredentials) { case "windows": username = Environment.UserName; break; case "custom": username = Settings.Default.DefaultUsername; break; } } if (!string.IsNullOrEmpty(InterfaceControl.Info?.Password)) { password = InterfaceControl.Info.Password; } else { if (Settings.Default.EmptyCredentials == "custom") { var cryptographyProvider = new LegacyRijndaelCryptographyProvider(); password = cryptographyProvider.Decrypt(Settings.Default.DefaultPassword, Runtime.EncryptionKey); } } arguments.Add("-" + (int)PuttySSHVersion); if (!Force.HasFlag(ConnectionInfo.Force.NoCredentials)) { if (!string.IsNullOrEmpty(username)) { arguments.Add("-l", username); } if (!string.IsNullOrEmpty(password)) { arguments.Add("-pw", password); } } } arguments.Add("-P", InterfaceControl.Info.Port.ToString()); arguments.Add(InterfaceControl.Info.Hostname); } if (_isPuttyNg) { arguments.Add("-hwndparent", InterfaceControl.Handle.ToString()); } PuttyProcess.StartInfo.Arguments = arguments.ToString(); PuttyProcess.EnableRaisingEvents = true; PuttyProcess.Exited += ProcessExited; PuttyProcess.Start(); PuttyProcess.WaitForInputIdle(Settings.Default.MaxPuttyWaitTime * 1000); var startTicks = Environment.TickCount; while (PuttyHandle.ToInt32() == 0 & Environment.TickCount < startTicks + Settings.Default.MaxPuttyWaitTime * 1000) { if (_isPuttyNg) { PuttyHandle = NativeMethods.FindWindowEx( InterfaceControl.Handle, new IntPtr(0), null, null); } else { PuttyProcess.Refresh(); PuttyHandle = PuttyProcess.MainWindowHandle; } if (PuttyHandle.ToInt32() == 0) { Thread.Sleep(0); } } if (!_isPuttyNg) { NativeMethods.SetParent(PuttyHandle, InterfaceControl.Handle); } Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, Language.strPuttyStuff, true); Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, string.Format(Language.strPuttyHandle, PuttyHandle), true); Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, string.Format(Language.strPuttyTitle, PuttyProcess.MainWindowTitle), true); Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, string.Format(Language.strPuttyParentHandle, InterfaceControl.Parent.Handle), true); Resize(this, new EventArgs()); base.Connect(); return(true); } catch (Exception ex) { Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, Language.strPuttyConnectionFailed + Environment.NewLine + ex.Message); return(false); } }
protected override void SetArguments() { CommandLineArguments.Add("update"); CommandLineArguments.Add($"\"{DirectoryToUpdate}\""); }
protected override void SetArguments() { CommandLineArguments.Add($"restore {Target}"); }
protected override void SetArguments() { CommandLineArguments.Add("start"); CommandLineArguments.Add("apppool"); CommandLineArguments.Add($"/apppool.name:\"{AppPoolName}\""); }
protected override void SetArguments() { CommandLineArguments.Add(CommandLineParameters); }
public override bool Connect() { try { if (!File.Exists(PuttyPath)) { throw new Exception("PuTTY not found."); } _isPuttyNg = IsFilePuttyNg(PuttyPath); PuttyProcess = new Process(); var _with1 = PuttyProcess.StartInfo; _with1.UseShellExecute = false; _with1.FileName = PuttyPath; var arguments = new CommandLineArguments { EscapeForShell = false }; arguments.Add("-load", InterfaceControl.Info.PuttySession); arguments.Add("-" + _PuttyProtocol); if (_PuttyProtocol == Putty_Protocol.ssh) { string username = ""; string password = ""; if (!string.IsNullOrEmpty(InterfaceControl.Info.Username)) { username = InterfaceControl.Info.Username; } else { if (Settings.Default.EmptyCredentials == "windows") { username = Environment.UserName; } else if (Settings.Default.EmptyCredentials == "custom") { username = Settings.Default.DefaultUsername; } } if (!string.IsNullOrEmpty(InterfaceControl.Info.Password)) { password = InterfaceControl.Info.Password; } else { if (Settings.Default.EmptyCredentials == "custom") { password = Security.Crypt.Decrypt(Settings.Default.DefaultPassword, AppInfo.General.EncryptionKey); } } arguments.Add("-" + (int)_PuttySSHVersion); if (!string.IsNullOrEmpty(username)) { arguments.Add("-l", username); } if (!string.IsNullOrEmpty(password)) { arguments.Add("-pw", password); } } arguments.Add("-P", InterfaceControl.Info.Port.ToString()); arguments.Add(InterfaceControl.Info.Hostname); if (_isPuttyNg) { arguments.Add("-hwndparent", InterfaceControl.Handle.ToString()); } _with1.Arguments = arguments.ToString(); //REMOVE IN RELEASE! #if DEBUG Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, "PuTTY Arguments: " + PuttyProcess.StartInfo.Arguments, true); Debug.WriteLine("PuTTY Arguments: " + PuttyProcess.StartInfo.Arguments); #endif PuttyProcess.EnableRaisingEvents = true; PuttyProcess.Exited += ProcessExited; PuttyProcess.Start(); PuttyProcess.WaitForInputIdle(Settings.Default.MaxPuttyWaitTime * 1000); int startTicks = Environment.TickCount; while (PuttyHandle.ToInt32() == 0 & Environment.TickCount < startTicks + (Settings.Default.MaxPuttyWaitTime * 1000)) { if (_isPuttyNg) { PuttyHandle = Native.FindWindowEx(InterfaceControl.Handle, IntPtr.Zero, Constants.vbNullString, Constants.vbNullString); } else { PuttyProcess.Refresh(); PuttyHandle = PuttyProcess.MainWindowHandle; } if (PuttyHandle.ToInt32() == 0) { Thread.Sleep(50); } } if (!_isPuttyNg) { Native.SetParent(PuttyHandle, InterfaceControl.Handle); } Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, Language.strPuttyStuff, true); Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, string.Format(Language.strPuttyHandle, PuttyHandle), true); Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, string.Format(Language.strPuttyTitle, PuttyProcess.MainWindowTitle), true); Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, string.Format(Language.strPuttyParentHandle, InterfaceControl.Parent.Handle), true); Resize(this, new EventArgs()); base.Connect(); return(true); } catch (Exception ex) { Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, Language.strPuttyConnectionFailed + Constants.vbNewLine + ex.Message); return(false); } }
public override bool Connect() { try { _isPuttyNg = IsFilePuttyNg(PuttyPath); PuttyProcess = new Process(); var _with1 = PuttyProcess.StartInfo; _with1.UseShellExecute = false; _with1.FileName = _PuttyPath; CommandLineArguments arguments = new CommandLineArguments(); arguments.EscapeForShell = false; arguments.Add("-load", InterfaceControl.Info.PuttySession); arguments.Add("-" + _PuttyProtocol.ToString()); if (_PuttyProtocol == Putty_Protocol.ssh) { string username = ""; string password = ""; if (!string.IsNullOrEmpty(InterfaceControl.Info.Username)) { username = InterfaceControl.Info.Username; } else { if (Settings.Default.EmptyCredentials == "windows") { username = Environment.UserName; } else if (Settings.Default.EmptyCredentials == "custom") { username = Settings.Default.DefaultUsername; } } if (!string.IsNullOrEmpty(InterfaceControl.Info.Password)) { password = InterfaceControl.Info.Password; } else { if (Settings.Default.EmptyCredentials == "custom") { password = Security.Crypt.Decrypt(Settings.Default.DefaultPassword, AppInfo.General.EncryptionKey); } } arguments.Add("-" + (int)_PuttySSHVersion); arguments.Add("-l", username); arguments.Add("-pw", password); } arguments.Add("-P", InterfaceControl.Info.Port.ToString()); arguments.Add(InterfaceControl.Info.Hostname); if (_isPuttyNg) { arguments.Add("-hwndparent", InterfaceControl.Handle.ToString()); } _with1.Arguments = arguments.ToString(); //REMOVE IN RELEASE! #if DEBUG Runtime.MessageCollector.AddMessage(Messages.MessageClass.InformationMsg, "PuTTY Arguments: " + PuttyProcess.StartInfo.Arguments, true); Debug.WriteLine("PuTTY Arguments: " + PuttyProcess.StartInfo.Arguments); #endif PuttyProcess.EnableRaisingEvents = true; PuttyProcess.Exited += ProcessExited; PuttyProcess.Start(); PuttyProcess.WaitForInputIdle(Settings.Default.MaxPuttyWaitTime * 1000); int startTicks = Environment.TickCount; while (PuttyHandle.ToInt32() == 0 & Environment.TickCount < startTicks + (Settings.Default.MaxPuttyWaitTime * 1000)) { if (_isPuttyNg) { PuttyHandle = Native.FindWindowEx(InterfaceControl.Handle, IntPtr.Zero, Constants.vbNullString, Constants.vbNullString); } else { PuttyProcess.Refresh(); PuttyHandle = PuttyProcess.MainWindowHandle; } if (PuttyHandle.ToInt32() == 0) Thread.Sleep(50); } if (!_isPuttyNg) { Native.SetParent(PuttyHandle, InterfaceControl.Handle); } Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, Language.strPuttyStuff, true); Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, string.Format(Language.strPuttyHandle, PuttyHandle.ToString()), true); Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, string.Format(Language.strPuttyTitle, PuttyProcess.MainWindowTitle), true); Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, string.Format(Language.strPuttyParentHandle, InterfaceControl.Parent.Handle.ToString()), true); Resize(this, new EventArgs()); base.Connect(); return true; } catch (Exception ex) { Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, Language.strPuttyConnectionFailed + Constants.vbNewLine + ex.Message); return false; } }