Sign in to follow this  
Followers 0
Nomis

Exit Options

4 posts in this topic

Afternoon all, I'm relatively new to this and I have created a simple script that will create a new folder with the current time/date, this works well but I what to use it in a batch file, I'll try to explain but sorry if I don't get it right first time.

So I want to have the exit code as the option selectd in the command line,

EX.

if I added DMY at the command line

then the exit code would be the current Day/Month/Year. (14072010)

Is this possible ??

Thanks Simon

If $CmdLine[0] < 1 Then

MsgBox(4096, "Error", "No Command Line Options Detected")

EndIf

$HM = @HOUR & @MIN

$Div = "-"

$DMY = @MDAY & @MON & @YEAR

If $CmdLine[1] = "HM" Then

DirCreate(@WorkingDir & "\" & $HM)

EndIf

If $CmdLine[1] = "DMY" Then

DirCreate(@WorkingDir & "\" & $DMY)

EndIf

If $CmdLine[1] = "ALL" Then

DirCreate(@WorkingDir & "\" & $HM & $Div & $DMY)

EndIf

Exit

Share this post


Link to post
Share on other sites



Global $exitcode = 0



If $CmdLine[0] < 1 Then

MsgBox(4096, "Error", "No Command Line Options Detected")

EndIf



$HM = @HOUR & @MIN

$Div = "-"

$DMY = @MDAY & @MON & @YEAR



If $CmdLine[1] = "HM" Then

DirCreate(@WorkingDir & "\" & $HM)

$exitcode = $HM

EndIf

If $CmdLine[1] = "DMY" Then

DirCreate(@WorkingDir & "\" & $DMY)

$exitcode = $DMY

EndIf

If $CmdLine[1] = "ALL" Then

DirCreate(@WorkingDir & "\" & $HM & $Div & $DMY)

EndIf



Exit $exitcode


AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

Hi John, thanks for that but now for the dumb question, I have been using %ERRORLEVEL% to show the exit level from the application but I'm only getting 9009 regardless the command line option I'm using.

Should I be using a different variable, I have added a MSGBOX at the end to confirm the exitcode string and that is working within the application but does not seem to exit with the correct data?

Simon

Global $exitcode = 0

If $CmdLine[0] < 1 Then
MsgBox(4096, "Error", "No Command Line Options Detected")
EndIf

$HM = @HOUR & @MIN
$Div = "-"
$DMY = @MDAY & @MON & @YEAR

If $CmdLine[1] = "HM" Then
DirCreate(@WorkingDir & "\" & $HM)
$exitcode = $HM

EndIf
If $CmdLine[1] = "DMY" Then
DirCreate(@WorkingDir & "\" & $DMY)
$exitcode = $DMY
EndIf
If $CmdLine[1] = "ALL" Then
DirCreate(@WorkingDir & "\" & $HM & $Div & $DMY)
$exitcode = $HM & $Div & $DMY
EndIf

MsgBox(4096, "Error", $exitcode)

Exit $exitcode

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