Jump to content
Sign in to follow this  

DOS console alert if bad parameters

Recommended Posts


hello to all,

can't find hint about bad or missing parameters.

run exe in DOS mode that need 2 or more par,

if user not respect rules exe return usage metod

find only exit if parameters is missing.

If $CmdLine[0] = 0 Then



i want an output error on DOS console


dir /? -> usage switches

myapplication.exe [without par] -> usage method

Share this post

Link to post
Share on other sites

I find in manual this :



The purpose for this function is to write to a console which many popular text editors can read.

This does not write to a DOS console. < -------------------- !


I want output message to DOS console...

Share this post

Link to post
Share on other sites


You need the latest SciTe editor AutoItWrapper option to make a CUI Portable Executable

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

; compile as CUI and run

; NOTE: requires latest version of SciTe editor or autoitwrapper with compile option 
; to change PE header subsystem to CUI instead of GUI (or get makecui.exe)
; note the compiler directive: #AutoIt3Wrapper_Change2CUI=y

; needs error handling for duplicate commandline options e.g. @ScriptName  /option1 /option1
; would meet minimum requirement of 2 params but commands are duplicates.

If Not @Compiled Then Exit

; optional commandline file info
Global $properties
Global $aFileInfo[2]
$aFileInfo[0] = "FileVersion"
$aFileInfo[1] = "Language"

If Not $CmdLine[0] Then ; empty commandline
    ConsoleWrite(@CRLF & "Missing commandline parameters" & @CRLF & _
            "Type " & @ScriptName & " /? for help" & @CRLF)
    Switch $CmdLine[1] ; single commands allowed if one of below params
        Case '/?' ; /? used so show help then exit
            ConsoleWrite(@CRLF & "Command line requires minimum of 2 parameters to run" & @CRLF & _
                    "unless using '/?' for help or 'Info' for program information" & @CRLF & _
                    "Enter parameters separated by a space and preceded by '/'" & @CRLF & _
                    "e.g. " & @ScriptName & " /option1 /option2")
        Case '/Info'; (optional) show program details then exit
            For $i = 0 To UBound($aFileInfo, 1) - 1
                $properties &= $aFileInfo[$i] & " : " & FileGetVersion(@AutoItExe, $aFileInfo[$i]) & @CRLF
            ConsoleWrite(@CRLF & "AutoIt3 Compiled Script Info" & @CRLF & $properties)

    If $CmdLine[0] < 2 Then ; Less then 2 parameters so show help then exit
        ConsoleWrite(@CRLF & "Minimum number of commandline parameters with exception of '/?' or 'Info' is two:" & @CRLF & _
                "Type " & @ScriptName & " /? for help" & @CRLF)
    For $element In $CmdLine
        Switch $element
            Case "/option1"
                ConsoleWrite("You chose option1" & @CRLF)
            Case "/option2"
                ConsoleWrite("You chose option2" & @CRLF)
            Case "/option3"
                ConsoleWrite("You chose option3" & @CRLF)

I see fascists...

Share this post

Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.