Skip to content

Instantly share code, notes, and snippets.

@buschtoens
Last active October 14, 2015 00:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save buschtoens/4281665 to your computer and use it in GitHub Desktop.
Save buschtoens/4281665 to your computer and use it in GitHub Desktop.
Simple power utility for starting processes
Set objShell = CreateObject("Shell.Application")
intOffset = 0
' get action
strAction = "open"
If (WScript.Arguments.Named.Exists("action")) Then
intOffset = intOffset + 1
Select Case WScript.Arguments.Named.Item("action")
Case "elevate" strAction = "runas"
Case "open" strAction = "open"
Case "read" strAction = "read"
Case "print" strAction = "print"
Case Else strAction = "open"
End Select
End If
' get display mode
intMode = 1
If (WScript.Arguments.Named.Exists("display")) Then
intOffset = intOffset + 1
Select Case WScript.Arguments.Named.Item("display")
Case "0" intMode = 0
Case "false" intMode = 0
Case "hide" intMode = 0
Case "hidden" intMode = 0
Case Else intMode = 1
End Select
End If
' get arguments
strExec = ""
For i = intOffset To WScript.Arguments.Count-1
strExec = strExec & " " & WScript.Arguments(i)
Next
' execute application
If (WScript.Arguments.Count >= 1) Then
objShell.ShellExecute "cmd", "/c " & strExec, "", strAction, intMode
Else
WScript.Quit
End If
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment