Skip to content

Instantly share code, notes, and snippets.

@fehC
Last active August 29, 2015 14:17
Show Gist options
  • Save fehC/2852e30f462b893ae31d to your computer and use it in GitHub Desktop.
Save fehC/2852e30f462b893ae31d to your computer and use it in GitHub Desktop.
Get raw command-line that was passed to script, including quotes
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