├── DummyConsoleApplication ├── DummyConsoleApplication.csproj ├── Program.cs └── Options.cs ├── publish.bat ├── ConsoleAppLauncher.Samples ├── ConsoleAppLauncher.Samples.csproj ├── Program.cs ├── Samples.cs ├── SysInfo.cs ├── Samples.resx └── Samples.Designer.cs ├── ConsoleAppLauncher ├── ConsoleOutputEventArgs.cs ├── ConsoleAppLauncher.csproj ├── Win32.cs ├── IConsoleApp.cs └── ConsoleApp.cs ├── .gitattributes ├── ConsoleAppLauncher.Tests ├── ConsoleAppLauncher.Tests.csproj └── ConsoleAppTest.cs ├── license.txt ├── .gitignore ├── readme.md └── ConsoleAppLauncher.sln /DummyConsoleApplication/DummyConsoleApplication.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net45 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /publish.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | pushd %~dp0 3 | 4 | echo Pushing NuGet package to nuget.org... 5 | dotnet nuget push "ConsoleAppLauncher\bin\Release\ConsoleAppLauncher.2.0.0.nupkg" --source https://api.nuget.org/v3/index.json --api-key %1 6 | 7 | :exit 8 | echo Done. 9 | popd 10 | 11 | -------------------------------------------------------------------------------- /ConsoleAppLauncher.Samples/ConsoleAppLauncher.Samples.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | WinExe 5 | netcoreapp3.1 6 | true 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /ConsoleAppLauncher/ConsoleOutputEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SlavaGu.ConsoleAppLauncher 4 | { 5 | public class ConsoleOutputEventArgs : EventArgs 6 | { 7 | public ConsoleOutputEventArgs(string line, bool isError) 8 | { 9 | Line = line; 10 | IsError = isError; 11 | } 12 | 13 | public string Line { get; private set; } 14 | public bool IsError { get; private set; } 15 | } 16 | } -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | *.sln merge=union 7 | *.csproj merge=union 8 | *.vbproj merge=union 9 | *.fsproj merge=union 10 | *.dbproj merge=union 11 | 12 | # Standard to msysgit 13 | *.doc diff=astextplain 14 | *.DOC diff=astextplain 15 | *.docx diff=astextplain 16 | *.DOCX diff=astextplain 17 | *.dot diff=astextplain 18 | *.DOT diff=astextplain 19 | *.pdf diff=astextplain 20 | *.PDF diff=astextplain 21 | *.rtf diff=astextplain 22 | *.RTF diff=astextplain 23 | -------------------------------------------------------------------------------- /ConsoleAppLauncher.Samples/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Windows.Forms; 4 | using SlavaGu.ConsoleAppLauncher.Samples; 5 | 6 | namespace ConsoleAppLauncher.Samples 7 | { 8 | static class Program 9 | { 10 | /// 11 | /// The main entry point for the application. 12 | /// 13 | [STAThread] 14 | static void Main() 15 | { 16 | Application.SetHighDpiMode(HighDpiMode.SystemAware); 17 | Application.EnableVisualStyles(); 18 | Application.SetCompatibleTextRenderingDefault(false); 19 | Application.Run(new Form1()); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /ConsoleAppLauncher.Tests/ConsoleAppLauncher.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net45 5 | false 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /ConsoleAppLauncher.Samples/Samples.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows.Forms; 3 | 4 | namespace SlavaGu.ConsoleAppLauncher.Samples 5 | { 6 | public partial class Form1 : Form 7 | { 8 | public Form1() 9 | { 10 | InitializeComponent(); 11 | } 12 | 13 | private void buttonVer_Click(object sender, EventArgs e) 14 | { 15 | labelVer.Text = SysInfo.GetWindowsVersion(); 16 | } 17 | 18 | private void buttonGetIpAddress_Click(object sender, EventArgs e) 19 | { 20 | labelIpAddress.Text = SysInfo.GetIpAddress(); 21 | } 22 | 23 | private void buttonPing_Click(object sender, EventArgs e) 24 | { 25 | SysInfo.PingUrl("google.com", reply => BeginInvoke((MethodInvoker)delegate { labelPing.Text = reply; })); 26 | } 27 | 28 | private void buttonSkype_Click(object sender, EventArgs e) 29 | { 30 | labelSkype.Text = SysInfo.GetFirewallRule("Skype"); 31 | } 32 | 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /license.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | Copyright (c) 2013 Slava Guzenko 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | 6 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /ConsoleAppLauncher/ConsoleAppLauncher.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net4;net45;net5;netcoreapp3.1;netstandard21 5 | true 6 | ConsoleAppLauncher 7 | Slava Guzenko 8 | 9 | Console Application wrapper for .NET. It captures all the output generated in the console and provides simple interface to start, show progress, and close console application. 10 | 11 | https://github.com/slavagu/ConsoleAppLauncher 12 | https://raw.githubusercontent.com/slavagu/ConsoleAppLauncher/master/license.txt 13 | false 14 | Console Wrapper ConsoleApp ConsoleApplication Process Ngen 15 | 16 | 17 | 18 | 2.0.0 19 | Targeting multiple frameworks including .NET Core 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /ConsoleAppLauncher.Samples/SysInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text.RegularExpressions; 3 | 4 | namespace SlavaGu.ConsoleAppLauncher.Samples 5 | { 6 | public class SysInfo 7 | { 8 | /// 9 | /// Run simplest shell command and return its output. 10 | /// 11 | /// 12 | public static string GetWindowsVersion() 13 | { 14 | return ConsoleApp.Run("cmd", "/c ver").Output.Trim(); 15 | } 16 | 17 | /// 18 | /// Run ipconfig.exe and return matching line. 19 | /// 20 | /// 21 | public static string GetIpAddress() 22 | { 23 | var output = ConsoleApp.Run("ipconfig").Output; 24 | var match = Regex.Match(output, "IPv4 Address.*: (?.*)"); 25 | return match.Success ? match.Groups["addr"].Value : ""; 26 | } 27 | 28 | /// 29 | /// Run ping.exe asynchronously and return roundtrip times back to the caller in a callback 30 | /// 31 | /// 32 | /// 33 | public static void PingUrl(string url, Action replyHandler) 34 | { 35 | var regex = new Regex("(time=|Average = )(?