commit 14fb19920633cd28fbec75e8002d6cd9f4056dd7 Author: Eveldee Date: Sat Dec 4 11:30:41 2021 +0100 Initial Commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e99a839 --- /dev/null +++ b/.gitignore @@ -0,0 +1,592 @@ + +# Created by https://www.toptal.com/developers/gitignore/api/visualstudio,visualstudiocode,csharp,dotnetcore +# Edit at https://www.toptal.com/developers/gitignore?templates=visualstudio,visualstudiocode,csharp,dotnetcore + +### Csharp ### +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.tlog +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Nuget personal access tokens and Credentials +# nuget.config + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd + +# VS Code files for those working on multiple tools +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +*.code-workspace + +# Local History for Visual Studio Code +.history/ + +# Windows Installer files from build outputs +*.cab +*.msi +*.msix +*.msm +*.msp + +# JetBrains Rider +.idea/ +*.sln.iml + +### DotnetCore ### +# .NET Core build folders +bin/ +obj/ + +# Common node modules locations +/node_modules +/wwwroot/node_modules + +### VisualStudioCode ### + +# Local History for Visual Studio Code + +### VisualStudioCode Patch ### +# Ignore all local history of files +.history +.ionide + +# Support for Project snippet scope +!.vscode/*.code-snippets + +### VisualStudio ### + +# User-specific files + +# User-specific files (MonoDevelop/Xamarin Studio) + +# Mono auto generated files + +# Build results + +# Visual Studio 2015/2017 cache/options directory +# Uncomment if you have tasks that create the project's static files in wwwroot + +# Visual Studio 2017 auto generated files + +# MSTest test Results + +# NUnit + +# Build Results of an ATL Project + +# Benchmark Results + +# .NET Core + +# ASP.NET Scaffolding + +# StyleCop + +# Files built by Visual Studio + +# Chutzpah Test files + +# Visual C++ cache files + +# Visual Studio profiler + +# Visual Studio Trace Files + +# TFS 2012 Local Workspace + +# Guidance Automation Toolkit + +# ReSharper is a .NET coding add-in + +# TeamCity is a build add-in + +# DotCover is a Code Coverage Tool + +# AxoCover is a Code Coverage Tool + +# Coverlet is a free, cross platform Code Coverage Tool + +# Visual Studio code coverage results + +# NCrunch + +# MightyMoose + +# Web workbench (sass) + +# Installshield output folder + +# DocProject is a documentation generator add-in + +# Click-Once directory + +# Publish Web Output +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted + +# NuGet Packages +# NuGet Symbol Packages +# The packages folder can be ignored because of Package Restore +# except build/, which is used as an MSBuild target. +# Uncomment if necessary however generally it will be regenerated when needed +# NuGet v3's project.json files produces more ignorable files + +# Nuget personal access tokens and Credentials +# nuget.config + +# Microsoft Azure Build Output + +# Microsoft Azure Emulator + +# Windows Store app package directories and files + +# Visual Studio cache files +# files ending in .cache can be ignored +# but keep track of directories ending in .cache + +# Others + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) + +# RIA/Silverlight projects + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) + +# SQL Server files + +# Business Intelligence projects + +# Microsoft Fakes + +# GhostDoc plugin setting file + +# Node.js Tools for Visual Studio + +# Visual Studio 6 build log + +# Visual Studio 6 workspace options file + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) + +# Visual Studio LightSwitch build output + +# Paket dependency manager + +# FAKE - F# Make + +# CodeRush personal settings + +# Python Tools for Visual Studio (PTVS) + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio + +# Telerik's JustMock configuration file + +# BizTalk build output + +# OpenCover UI analysis results + +# Azure Stream Analytics local run output + +# MSBuild Binary and Structured Log + +# NVidia Nsight GPU debugger configuration file + +# MFractors (Xamarin productivity tool) working folder + +# Local History for Visual Studio + +# BeatPulse healthcheck temp database + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 + +# Ionide (cross platform F# VS Code tools) working folder + +# Fody - auto-generated XML schema + +# VS Code files for those working on multiple tools + +# Local History for Visual Studio Code + +# Windows Installer files from build outputs + +# JetBrains Rider + +### VisualStudio Patch ### +# Additional files built by Visual Studio + +# End of https://www.toptal.com/developers/gitignore/api/visualstudio,visualstudiocode,csharp,dotnetcore diff --git a/ExeLauncher.sln b/ExeLauncher.sln new file mode 100644 index 0000000..043bc6b --- /dev/null +++ b/ExeLauncher.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29609.76 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExeLauncher", "ExeLauncher\ExeLauncher.csproj", "{E002E8E2-D13A-4995-ABAB-DF7451FDA464}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E002E8E2-D13A-4995-ABAB-DF7451FDA464}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E002E8E2-D13A-4995-ABAB-DF7451FDA464}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E002E8E2-D13A-4995-ABAB-DF7451FDA464}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E002E8E2-D13A-4995-ABAB-DF7451FDA464}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {880616E9-169A-4E91-8265-3144E4316DB1} + EndGlobalSection +EndGlobal diff --git a/ExeLauncher/App.config b/ExeLauncher/App.config new file mode 100644 index 0000000..193aecc --- /dev/null +++ b/ExeLauncher/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ExeLauncher/Code.cs b/ExeLauncher/Code.cs new file mode 100644 index 0000000..02ecd47 --- /dev/null +++ b/ExeLauncher/Code.cs @@ -0,0 +1,45 @@ +using System.Diagnostics; +using System; + +namespace ExeLauncher +{ + class Program + { + const string Paths = @"%Paths%"; + const string Arguments = @"%Arguments%"; + const string WorkingDirectories = @"%WorkingDirectories%"; + + static void Main(string[] args) + { + var paths = Paths.Split('§'); + var arguments = Arguments.Split('§'); + var workingDirectories = WorkingDirectories.Split('§'); + + for (int i = 0; i < paths.Length; i++) + { + var path = paths[i]; + var argument = arguments[i]; + var workingDirectory = workingDirectories[i]; + + if (args.Length > 0) + { + Console.WriteLine(path); + Console.WriteLine(argument); + Console.WriteLine(workingDirectory); + + continue; + } + + new Process() + { + StartInfo = new ProcessStartInfo() + { + FileName = path, + Arguments = argument, + WorkingDirectory = workingDirectory + } + }.Start(); + } + } + } +} \ No newline at end of file diff --git a/ExeLauncher/ExeLauncher.csproj b/ExeLauncher/ExeLauncher.csproj new file mode 100644 index 0000000..eb8ffdd --- /dev/null +++ b/ExeLauncher/ExeLauncher.csproj @@ -0,0 +1,91 @@ + + + + + Debug + AnyCPU + {E002E8E2-D13A-4995-ABAB-DF7451FDA464} + Exe + ExeLauncher + ExeLauncher + v4.8 + 512 + true + true + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + icon.ico + + + + + + + + + + + + + + + + + + + + + + + + + + False + Microsoft .NET Framework 4.8 %28x86 et x64%29 + true + + + False + .NET Framework 3.5 SP1 + false + + + + \ No newline at end of file diff --git a/ExeLauncher/Program.cs b/ExeLauncher/Program.cs new file mode 100644 index 0000000..ca38b38 --- /dev/null +++ b/ExeLauncher/Program.cs @@ -0,0 +1,133 @@ +using Microsoft.CSharp; +using System; +using System.CodeDom.Compiler; +using System.Diagnostics; +using System.IO; +using System.Reflection; +using System.Windows.Forms; + +namespace ExeLauncher +{ + class Program + { + const string Paths = "%Paths%"; + const string Arguments = "%Arguments%"; + const string WorkingDirectories = "%WorkingDirectories%"; + + static string code; + + [STAThread] + static void Main(string[] args) + { + var file = Assembly.GetExecutingAssembly().GetManifestResourceStream("ExeLauncher.Code.cs"); + var reader = new StreamReader(file); + + code = reader.ReadToEnd(); + + reader.Close(); + + string path, arguments, workingDirectory, icon; + + Console.Write("Path: "); + path = Console.ReadLine(); + + Console.Write("Arguments: "); + arguments = Console.ReadLine(); + + Console.Write("Working Directory: "); + workingDirectory = Console.ReadLine(); + + Console.WriteLine("Choose an icon for the executable: "); + icon = GetIcon(); + + Console.WriteLine(); + + Console.WriteLine("Creating launcher with options: "); + Console.WriteLine($"Path: {path}"); + Console.WriteLine($"Arguments: {arguments}"); + Console.WriteLine($"Working directory: {workingDirectory}"); + + Console.WriteLine(); + Console.WriteLine("Choose a location to save the file."); + + var location = GetLocation(); + + Console.WriteLine(); + Console.WriteLine("Generating file..."); + + CreateExecutable(location, path, arguments, workingDirectory, icon); + + Console.WriteLine(); + Console.WriteLine("Done."); + Console.ReadKey(true); + } + + private static void CreateExecutable(string location, string paths, string arguments, string workingDirectories, string icon) + { + code = code.Replace(Paths, paths); + code = code.Replace(Arguments, arguments); + code = code.Replace(WorkingDirectories, workingDirectories); + + using (var codeProvider = new CSharpCodeProvider()) + { + var compilerParameters = new CompilerParameters() + { + CompilerOptions = $"-target:winexe -win32icon:\"{icon}\"", + GenerateExecutable = true, + OutputAssembly = location + }; + compilerParameters.ReferencedAssemblies.Add("System.dll"); + + var result = codeProvider.CompileAssemblyFromSource(compilerParameters, code); + + if (result.Errors.HasErrors) + { + Console.WriteLine("An error occured while compiling the executable: "); + foreach (var compilerError in result.Errors) + { + Console.WriteLine("\t{0}", compilerError.ToString()); + Console.WriteLine(); + } + } + } + } + + private static string GetIcon() + { + var dialog = new OpenFileDialog() + { + CheckFileExists = true, + Filter = "Icon|*.ico" + }; + + if (dialog.ShowDialog() == DialogResult.OK) + { + return dialog.FileName; + } + + return ""; + } + + private static string GetLocation() + { + var dialog = new SaveFileDialog() + { + AddExtension = true, + DefaultExt = ".exe", + FileName = "Run.exe", + Filter = "Executable|*.exe", + OverwritePrompt = true + }; + + if (dialog.ShowDialog() == DialogResult.OK) + { + return dialog.FileName; + } + + Environment.Exit(1); + + // Impossible to reach, but compiler complained, so... + return null; + } + } +} diff --git a/ExeLauncher/Properties/AssemblyInfo.cs b/ExeLauncher/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..847624e --- /dev/null +++ b/ExeLauncher/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Les informations générales relatives à un assembly dépendent de +// l'ensemble d'attributs suivant. Changez les valeurs de ces attributs pour modifier les informations +// associées à un assembly. +[assembly: AssemblyTitle("ExeLauncher")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("ExeLauncher")] +[assembly: AssemblyCopyright("Copyright © 2019")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// L'affectation de la valeur false à ComVisible rend les types invisibles dans cet assembly +// aux composants COM. Si vous devez accéder à un type dans cet assembly à partir de +// COM, affectez la valeur true à l'attribut ComVisible sur ce type. +[assembly: ComVisible(false)] + +// Le GUID suivant est pour l'ID de la typelib si ce projet est exposé à COM +[assembly: Guid("e002e8e2-d13a-4995-abab-df7451fda464")] + +// Les informations de version pour un assembly se composent des quatre valeurs suivantes : +// +// Version principale +// Version secondaire +// Numéro de build +// Révision +// +// Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de build et de révision par défaut +// en utilisant '*', comme indiqué ci-dessous : +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/ExeLauncher/icon.ico b/ExeLauncher/icon.ico new file mode 100644 index 0000000..42486f9 Binary files /dev/null and b/ExeLauncher/icon.ico differ