private void SetProcessProperties(Process process, ConnectionInfo startConnectionInfo) { var argParser = new ExternalToolArgumentParser(startConnectionInfo); process.StartInfo.UseShellExecute = true; process.StartInfo.FileName = argParser.ParseArguments(FileName); process.StartInfo.Arguments = argParser.ParseArguments(Arguments); }
public override bool Connect() { try { if (_externalTool.TryIntegrate == false) { _externalTool.Start(InterfaceControl.Info); Close(); return false; } ExternalToolArgumentParser argParser = new ExternalToolArgumentParser(_externalTool.ConnectionInfo); _process = new Process(); _process.StartInfo.UseShellExecute = true; _process.StartInfo.FileName = argParser.ParseArguments(_externalTool.FileName); _process.StartInfo.Arguments = argParser.ParseArguments(_externalTool.Arguments); _process.EnableRaisingEvents = true; _process.Exited += ProcessExited; _process.Start(); _process.WaitForInputIdle(Convert.ToInt32(Settings.Default.MaxPuttyWaitTime * 1000)); int startTicks = Environment.TickCount; while (_handle.ToInt32() == 0 & Environment.TickCount < startTicks + (Settings.Default.MaxPuttyWaitTime * 1000)) { _process.Refresh(); if (_process.MainWindowTitle != "Default IME") { _handle = _process.MainWindowHandle; } if (_handle.ToInt32() == 0) { Thread.Sleep(0); } } NativeMethods.SetParent(_handle, InterfaceControl.Handle); Runtime.MessageCollector.AddMessage(Messages.MessageClass.InformationMsg, Language.strIntAppStuff, true); Runtime.MessageCollector.AddMessage(Messages.MessageClass.InformationMsg, string.Format(Language.strIntAppHandle, _handle.ToString()), true); Runtime.MessageCollector.AddMessage(Messages.MessageClass.InformationMsg, string.Format(Language.strIntAppTitle, _process.MainWindowTitle), true); Runtime.MessageCollector.AddMessage(Messages.MessageClass.InformationMsg, string.Format(Language.strIntAppParentHandle, InterfaceControl.Parent.Handle.ToString()), true); Resize(this, new EventArgs()); base.Connect(); return true; } catch (Exception ex) { Runtime.MessageCollector.AddExceptionMessage(Language.strIntAppConnectionFailed, ex); return false; } }
private void SetProcessProperties(Process process, ConnectionInfo startConnectionInfo) { var argParser = new ExternalToolArgumentParser(startConnectionInfo); process.StartInfo.UseShellExecute = true; process.StartInfo.FileName = argParser.ParseArguments(FileName); process.StartInfo.Arguments = argParser.ParseArguments(Arguments); if (WorkingDir != "") { process.StartInfo.WorkingDirectory = argParser.ParseArguments(WorkingDir); } if (RunElevated) { process.StartInfo.Verb = "runas"; } }
public void NullConnectionInfoResultsInEmptyVariables() { var parser = new ExternalToolArgumentParser(null); var parsedText = parser.ParseArguments("test %USERNAME% test"); Assert.That(parsedText, Is.EqualTo("test test")); }
private void SetProcessProperties(Process process, ConnectionInfo startConnectionInfo) { ExternalToolArgumentParser argParser = new ExternalToolArgumentParser(startConnectionInfo); process.StartInfo.UseShellExecute = true; process.StartInfo.FileName = argParser.ParseArguments(FileName); process.StartInfo.Arguments = argParser.ParseArguments(Arguments); }