Trong Posted July 18, 2017 Share Posted July 18, 2017 Full Document: https://www.autoitscript.com/autoit3/docs/intro/running.htm Application used for checking CMD input into the application! (Attached with source) Use: testCMD.exe CMD1 CMD2 CMD3 CMD.n..Quick source: expandcollapse popup#NoTrayIcon ;~ #include <WinAPIShPath.au3> Global Const $iShow_MsgBox = 1, $iCmdLineRaw = @Compiled ? $CmdLineRaw : "" ;//; $CmdLineRaw ; StringReplace($CmdLineRaw, '/ErrorStdOut "' & @ScriptFullPath & '" ', "") Global $icmdMsgBox, $icmdConsole, $iCmdLine = _WinAPI_CommandLineToArgv($iCmdLineRaw) Global $ExeInfo = "-Execute: " & @ScriptFullPath & @CRLF & "-Working Dir: " & @WorkingDir Global $SysInfo = "> " & @OSVersion & "/" & @OSArch & "/" & @OSServicePack & " - UserName: " & @UserName & " (Is Admin = " & IsAdmin() & ")" ConsoleWrite(@CRLF & $SysInfo & @CRLF & "+ CommandLine Checker " & @CRLF) If @error Or ($iCmdLine[0] = 0) Then ConsoleWrite("! Error: no comnand line!" & @CRLF & @CRLF) If $iShow_MsgBox Then MsgBox(48 + 262144, "CommandLine Checker", "Error: no comnand line!" & @CRLF & @CRLF & $ExeInfo & @CRLF & @CRLF & $SysInfo) Exit 1 EndIf ConsoleWrite($ExeInfo & @CRLF & "+ Comnand List:" & @CRLF) For $i = 1 To $iCmdLine[0] $icmdConsole = "- CMD_" & $i & " = " & $iCmdLine[$i] & @CRLF ConsoleWrite($icmdConsole) $icmdMsgBox &= " " & $icmdConsole Next If $iShow_MsgBox Then MsgBox(64 + 262144, "CommandLine Checker", $ExeInfo & @CRLF & "+ Comnand List:" & @CRLF & $icmdMsgBox & @CRLF & @CRLF & $SysInfo) Exit 0 #Region Internal Functions :: WinAPIShPath.au3 Func _WinAPI_CommandLineToArgv($sCmd) Local $aResult[1] = [0] $sCmd = StringStripWS($sCmd, 1 + 2) ;$STR_STRIPLEADING = 1 / $STR_STRIPTRAILING = 2 If Not $sCmd Then Return $aResult EndIf Local $aRet = DllCall('shell32.dll', 'ptr', 'CommandLineToArgvW', 'wstr', $sCmd, 'int*', 0) If @error Or Not $aRet[0] Or (Not $aRet[2]) Then Return SetError(@error + 10, @extended, 0) Local $tPtr = DllStructCreate('ptr[' & $aRet[2] & ']', $aRet[0]) Dim $aResult[$aRet[2] + 1] = [$aRet[2]] For $i = 1 To $aRet[2] $aResult[$i] = _WinAPI_GetString(DllStructGetData($tPtr, 1, $i)) Next DllCall("kernel32.dll", "handle", "LocalFree", "handle", $aRet[0]) Return $aResult EndFunc ;==>_WinAPI_CommandLineToArgv Func _WinAPI_GetString($pString, $bUnicode = True) Local $iLength = _WinAPI_StrLen($pString, $bUnicode) If @error Or Not $iLength Then Return SetError(@error + 10, @extended, '') Local $tString = DllStructCreate(__Iif($bUnicode, 'wchar', 'char') & '[' & ($iLength + 1) & ']', $pString) If @error Then Return SetError(@error, @extended, '') Return SetExtended($iLength, DllStructGetData($tString, 1)) EndFunc ;==>_WinAPI_GetString Func _WinAPI_StrLen($pString, $bUnicode = True) Local $W = '' If $bUnicode Then $W = 'W' Local $aRet = DllCall('kernel32.dll', 'int', 'lstrlen' & $W, 'struct*', $pString) If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc ;==>_WinAPI_StrLen Func __Iif($bTest, $vTrue, $vFalse) Return $bTest ? $vTrue : $vFalse EndFunc ;==>__Iif #EndRegion Internal Functions :: WinAPIShPath.au3 ; * -----:| Dao Van Trong - TRONG.WIN CMDtest.zip Regards, Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now