From 218eb4ea210b18c20acc41105176a7dc0f8d9e05 Mon Sep 17 00:00:00 2001 From: Nelson LaQuet Date: Wed, 20 May 2015 03:22:34 -0500 Subject: [PATCH] Committed elevator's source --- tools/Elevator/.gitignore | 7 ++ tools/Elevator/Elevator.sln | 22 +++++++ tools/Elevator/Elevator/Elevator.csproj | 64 +++++++++++++++++++ tools/Elevator/Elevator/Program.cs | 54 ++++++++++++++++ .../Elevator/Properties/AssemblyInfo.cs | 36 +++++++++++ tools/Elevator/Elevator/app.config | 3 + tools/Elevator/Elevator/app.manifest | 11 ++++ tools/readme.md | 15 +++++ 8 files changed, 212 insertions(+) create mode 100644 tools/Elevator/.gitignore create mode 100644 tools/Elevator/Elevator.sln create mode 100644 tools/Elevator/Elevator/Elevator.csproj create mode 100644 tools/Elevator/Elevator/Program.cs create mode 100644 tools/Elevator/Elevator/Properties/AssemblyInfo.cs create mode 100644 tools/Elevator/Elevator/app.config create mode 100644 tools/Elevator/Elevator/app.manifest create mode 100644 tools/readme.md diff --git a/tools/Elevator/.gitignore b/tools/Elevator/.gitignore new file mode 100644 index 00000000..f35a7cf4 --- /dev/null +++ b/tools/Elevator/.gitignore @@ -0,0 +1,7 @@ +*.suo +*.user +*.sln.docstates +[Dd]ebug/ +[Rr]elease/ +*.obj +*.pdb \ No newline at end of file diff --git a/tools/Elevator/Elevator.sln b/tools/Elevator/Elevator.sln new file mode 100644 index 00000000..d7b3d63e --- /dev/null +++ b/tools/Elevator/Elevator.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.31101.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elevator", "Elevator\Elevator.csproj", "{456AA7CA-4262-40B2-A729-23B3B80D3980}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {456AA7CA-4262-40B2-A729-23B3B80D3980}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {456AA7CA-4262-40B2-A729-23B3B80D3980}.Debug|Any CPU.Build.0 = Debug|Any CPU + {456AA7CA-4262-40B2-A729-23B3B80D3980}.Release|Any CPU.ActiveCfg = Release|Any CPU + {456AA7CA-4262-40B2-A729-23B3B80D3980}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/tools/Elevator/Elevator/Elevator.csproj b/tools/Elevator/Elevator/Elevator.csproj new file mode 100644 index 00000000..96782606 --- /dev/null +++ b/tools/Elevator/Elevator/Elevator.csproj @@ -0,0 +1,64 @@ + + + + + Debug + AnyCPU + {456AA7CA-4262-40B2-A729-23B3B80D3980} + Exe + Properties + Elevator + Elevator + v4.5 + 512 + + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + false + + + AnyCPU + pdbonly + true + ..\..\..\vagrant\ + TRACE + prompt + 4 + false + + + app.manifest + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tools/Elevator/Elevator/Program.cs b/tools/Elevator/Elevator/Program.cs new file mode 100644 index 00000000..3df28a88 --- /dev/null +++ b/tools/Elevator/Elevator/Program.cs @@ -0,0 +1,54 @@ +using System; +using System.Diagnostics; +using System.IO; +using System.Linq; + +namespace Elevator +{ + class Program + { + static void Main(string[] args) + { + if (args.Length < 2) + { + Console.WriteLine("Usage: elevator.exe path program [arg1] [arg2] [arg3] ..."); + Console.ReadKey(); + return; + } + + var arguments = string.Join(" ", args.Skip(2).Select(t => string.Format("\"{0}\"", t))); + var fileName = args[1]; + + Console.WriteLine("Running: {0} {1}", fileName, arguments); + Console.WriteLine("----------------------------"); + + try + { + var process = new Process + { + StartInfo = + { + FileName = fileName, + Arguments = arguments, + UseShellExecute = false, + RedirectStandardInput = false, + WorkingDirectory = Path.GetFullPath(args[0]) + } + }; + + process.Start(); + process.WaitForExit(); + } + catch (Exception ex) + { + Console.ForegroundColor = ConsoleColor.Red; + Console.WriteLine(ex.Message); + Console.ForegroundColor = ConsoleColor.Gray; + } + + Console.WriteLine("----------------------------"); + Console.WriteLine("Press any key"); + Console.ReadKey(); + } + } +} diff --git a/tools/Elevator/Elevator/Properties/AssemblyInfo.cs b/tools/Elevator/Elevator/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..83de241e --- /dev/null +++ b/tools/Elevator/Elevator/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Elevator")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Elevator")] +[assembly: AssemblyCopyright("Copyright © 2015")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("90c222d4-7c89-43e3-954b-0632431d0b24")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/tools/Elevator/Elevator/app.config b/tools/Elevator/Elevator/app.config new file mode 100644 index 00000000..51278a45 --- /dev/null +++ b/tools/Elevator/Elevator/app.config @@ -0,0 +1,3 @@ + + + diff --git a/tools/Elevator/Elevator/app.manifest b/tools/Elevator/Elevator/app.manifest new file mode 100644 index 00000000..8a7821e0 --- /dev/null +++ b/tools/Elevator/Elevator/app.manifest @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/tools/readme.md b/tools/readme.md new file mode 100644 index 00000000..b33dce7c --- /dev/null +++ b/tools/readme.md @@ -0,0 +1,15 @@ +This folder contains tools for use with PFM. + +# Elevator +Elevator is a simple .net application that elevates whatever commands are passed into it to an admin context. + +This is required for the bat files that interact with the Vagrant VMWare provider on Windows. The provider requires that all commands on it are executed in an admin context. As a result, you would have to right click any bat that executes these commands and select "run as administrator". + +Elevator fixes this by doing this automatically, so you simply have to double click on the bat file and accept the UAC dialog. + +You use it simply be invoking +> elevator.exe path command arg1 arg2 arg3 ... + +Where "path" will be the working directory where the program is executed, "command" is the command you wish to execute, and "arg..." are the arguments you wish to supply to "command". + +Note that "path" is relative to the current working directory and can be a relative path. \ No newline at end of file