Last active
October 14, 2015 00:48
-
-
Save buschtoens/4281665 to your computer and use it in GitHub Desktop.
Simple power utility for starting processes
This file contains hidden or 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
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