Sign in to follow this  
Followers 0
MarkVR

Use command line arguments as variables

6 posts in this topic

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

Share this post


Link to post
Share on other sites



This will cover it as long as you have only one parameter:

If $CmdLine[0] > 0 Then
    $Var = $CmdLine[1]
EndIf

[sub]Quantum mechanics: The dreams stuff is made of[/sub]

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

This will cover it as long as you have only one parameter:

If $CmdLine[0] > 0 Then
    $Var = $CmdLine[1]
EndIf

Thank you

And thx Henry

Edited by MarkVR

Share this post


Link to post
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)

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

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

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  
Followers 0