Jump to content

Use command line arguments as variables


Recommended Posts

After I have compiled my exe I will be running it in a command window. What I want to achieve is almost the same as the now.exe if you know it.

c:\>now.exe Hello

Will return the date and time plus the "Hello". ie (09:30 - 14/04/08 Hello) in the command window. So I want my script/exe to look at the command line I type to run it and then set the argument "Hello" or what ever to a variable so that the exe will be able to use it.

Thanks in advance

Link to comment
Share on other sites

Hi MarkVR,

c:\>now.exe Hello

Will return the date and time plus the "Hello". ie (09:30 - 14/04/08 Hello) in the command window.

Try this:

If $CmdLine[0] > 0 Then
    $var = $CmdLine[1]
    ConsoleWrite(@HOUR & ":" & @MIN & " - " & @MDAY & "/" & @MON & "/" & StringRight(@YEAR, 2) & " " & $var)
    Exit
EndIf
Henry
Link to comment
Share on other sites

Ahh ok the consolewrite does not seem to work. This is how I did it thanks again for the input:

If $CmdLine[0] > 0 Then

$argument = $CmdLine[1]

EndIf

$Date = _DateTimeFormat( _NowCalc(),2)

$Time = @HOUR&":"&@MIN

$Output = $Date& " - "& $Time

run(@ComSpec &" /k echo " &$Output &" - " & $argument)

Link to comment
Share on other sites

Try to add this on the beginning:

#AutoIt3Wrapper_Change2CUI=y

Edit:

Also, what do you mean "does not seem to work"? Can you explain the issue? Is there an error generate when you perform compile?

Edited by henry1
Henry
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...