Skip to content

Instantly share code, notes, and snippets.

@silverkorn
Last active November 5, 2018 15:24
Show Gist options
  • Save silverkorn/1c10526cbba9b10d48af27327ac5501e to your computer and use it in GitHub Desktop.
Save silverkorn/1c10526cbba9b10d48af27327ac5501e to your computer and use it in GitHub Desktop.
Hide terminal pop up on Windows, like for Node's `pkg` binary output.
Dim objShell, objFSO, objFile, strArguments
Set objShell = WScript.CreateObject("WScript.shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile(WScript.ScriptFullName)
For Each strArgument in WScript.Arguments
strArguments = strArguments & " " & strArgument
Next
objShell.Run """" & objFSO.GetParentFolderName(objFile) & "\" & objFSO.GetBaseName(WScript.ScriptFullName) & ".exe""" & strArguments, 0, False
@silverkorn
Copy link
Author

silverkorn commented Nov 2, 2018

Just put it in the same directory as the executable and give it the same name but with the .vbs extension and use this script instead for your potential desktop shortcut.

This suggestion might not work properly with quoted arguments. If so, you might want to include this instead if judged necessary :
https://stackoverflow.com/questions/31095570/what-is-the-or-argument-list-equivalent-for-vbscript#answer-31100398
Or
https://stackoverflow.com/questions/40056204/how-do-i-get-raw-vbscript-command-line-arguments#answer-40056793

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment