Skip to content

Instantly share code, notes, and snippets.

@chponte
Last active March 4, 2019 18:24
Show Gist options
  • Save chponte/e17a5cc5b233439f1afa670469b24265 to your computer and use it in GitHub Desktop.
Save chponte/e17a5cc5b233439f1afa670469b24265 to your computer and use it in GitHub Desktop.
WSL Shortcut
' Simple command-line help.
select case WScript.Arguments(0)
case "-?", "/?", "-h", "--help"
WScript.echo "Usage: runHidden executable [...]" & vbNewLine & vbNewLine & "Runs the specified command hidden (without a visible window)."
WScript.Quit(0)
end select
' Separate the arguments into the executable name
' and a single string containing all arguments.
exe = WScript.Arguments(0)
sep = ""
for i = 1 to WScript.Arguments.Count -1
' Enclose arguments in "..." to preserve their original partitioning.
args = args & sep & """" & WScript.Arguments(i) & """"
sep = " "
next
' Execute the command with its window *hidden* (0)
WScript.CreateObject("Shell.Application").ShellExecute exe, args, "", "open", 0
Target: C:\Windows\System32\wscript.exe "path\to\launcher.vbs" "ubuntu1804.exe" "run" "command"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment