Created
July 21, 2022 23:59
-
-
Save EduenSarceno/371faff1e5a0350603f6e16277e79e09 to your computer and use it in GitHub Desktop.
This snippet allow you to proxy an executable, it's util when you need to put a program into %PATH%
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For compiling this you need a JScript.NET compiler. | |
// "%windir%\Microsoft.NET\Framework64\v4.0.30319\jsc.exe" /out:yourProgram.exe /target:winexe proxyMe.js | |
import System | |
import System.Diagnostics | |
const prg = 'C:\\Program Files\\Sublime Text\\subl.exe' | |
const args = getCommandLine() | |
function getCommandLine() { | |
const args = Environment.GetCommandLineArgs() | |
const ret = [] | |
for (var i = 1, l = args.length; i < l; i++) { | |
const arg = args[i] | |
.replace('\\', '\\\\') | |
.replace('"', '\\"') | |
ret.push('"' + arg +'"') | |
} | |
return ret.join(' ') | |
} | |
const process = createProcess() | |
process.WaitForExit() | |
function createProcess() { | |
const pinfo = new ProcessStartInfo | |
pinfo.FileName = prg | |
pinfo.Arguments = args | |
pinfo.CreateNoWindow = true | |
return Process.Start(pinfo) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment