Skip to content

Instantly share code, notes, and snippets.

@fernandofig
Last active August 25, 2019 12:38
Show Gist options
  • Save fernandofig/8785d5a1295791466754d9f6f320221c to your computer and use it in GitHub Desktop.
Save fernandofig/8785d5a1295791466754d9f6f320221c to your computer and use it in GitHub Desktop.
Run application with extended Windowing option (allowing for the window to be completely hidden - useful for terminal applications)
'Uso: RodaMinimz.vbs <TIPO_JANELA> <EXECUTAVEL> [OPCOES EXECUTAVEL]
' TIPO_JANELA:
' 0 Hides the window and activates another window.
' 1 Activates and displays a window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this flag when displaying the window for the first time.
' 2 Activates the window and displays it as a minimized window.
' 3 Activates the window and displays it as a maximized window.
' 4 Displays a window in its most recent size and position. The active window remains active.
' 5 Activates the window and displays it in its current size and position.
' 6 Minimizes the specified window and activates the next top-level window in the Z order.
' 7 Displays the window as a minimized window. The active window remains active.
' 8 Displays the window in its current state. The active window remains active.
' 9 Activates and displays the window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this flag when restoring a minimized window.
' 10 Sets the show-state based on the state of the program that started the application.
Dim FSO, Shell, CmdLine
If WScript.Arguments.Count < 2 Then
MsgBox "Este script requer o tipo de janela (numero) e nome da aplicação (e opcionalmente os parâmetros dela)!"
Wscript.Quit
End If
Set FSO = CreateObject("Scripting.FileSystemObject")
Set Shell = CreateObject("Wscript.Shell")
If Not FSO.FileExists(WScript.Arguments(1)) Then
MsgBox "Executável não existe!"
Wscript.Quit
End If
CmdLine = ""
foiWin = False
foiCmd = False
For Each opt in WScript.Arguments
If Not foiWin Then
foiWin = True
ElseIf Not foiCmd Then
foiCmd = True
Else
If CmdLine <> "" Then CmdLine = CmdLine + " "
CmdLine = CmdLine + opt
End If
Next
'MsgBox CmdLine
Shell.Run """" + WScript.Arguments(1) + """" + CmdLine, WScript.Arguments(0), False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment