Last active
August 29, 2015 14:17
-
-
Save fehC/2852e30f462b893ae31d to your computer and use it in GitHub Desktop.
Get raw command-line that was passed to script, including quotes
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
cmd_scriptCMD() | |
{ | |
for process in ComObjGet("winmgmts:").ExecQuery( "Select * from Win32_Process where ProcessId=" DllCall( "GetCurrentProcessId" ) ) | |
commandLine := process[ "commandLine" ] | |
SplitPath, a_scriptfullPath, scriptName | |
script_name_start_pos := instr( commandLine, scriptName ) | |
script_name_length := strLen( scriptName ) | |
isFirstCharQuote := subStr( commandLine, 1, 1 ) = """" ? 1 : 0 | |
commandLine := trim( subStr( commandLine, script_name_start_pos+script_name_length+isFirstCharQuote ) ) | |
return commandLine | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment