Sign in to follow this  
Followers 0
RedneckTech

Command Line Params

7 posts in this topic

Ive been trying this and the only sensible way i can come up with is as follows

$CmdLine[0] = 1
If $CmdLine[1] = "/F" Then
   MsgBox (0, "", "The Command has been forced")
ElseIf $CmdLine[1] = "/L" Then
   MsgBox (0, "", "The Log has been activated")
Else
   MsgBox (0, "", "No lines Detected, Try again dude!")
EndIf

Have Also Tried this:

$CmdLine[0] = 2
$CmdLine[1] = "/F"
$CmdLine[2] = "/L"
If $CmdLine[1] = "/F" Then
   MsgBox (0, "", "The Command has been forced")
ElseIf $CmdLine[1] = "/L" Then
   MsgBox (0, "", "The Log has been activated")
Else
   MsgBox (0, "", "No lines Detected, Try again dude!")
EndIf

Unfortunately, when I "Run" myscript.exe /F or myscript.exe /L I get "Error: Cannot assign values to constants."

Any advice?

And i came up with this after reading the help file, and searching the forums, so please dont just send me back to that help file page

Thanks in advance!

Share this post


Link to post
Share on other sites



Ive been trying this and the only sensible way i can come up with is as follows

$CmdLine[0] = 1
If $CmdLine[1] = "/F" Then
MsgBox (0, "", "The Command has been forced")
ElseIf $CmdLine[1] = "/L" Then
MsgBox (0, "", "The Log has been activated")
Else
MsgBox (0, "", "No lines Detected, Try again dude!")
EndIf

Have Also Tried this:

$CmdLine[0] = 2
$CmdLine[1] = "/F"
$CmdLine[2] = "/L"
If $CmdLine[1] = "/F" Then
MsgBox (0, "", "The Command has been forced")
ElseIf $CmdLine[1] = "/L" Then
MsgBox (0, "", "The Log has been activated")
Else
MsgBox (0, "", "No lines Detected, Try again dude!")
EndIf

Unfortunately, when I "Run" myscript.exe /F or myscript.exe /L I get "Error: Cannot assign values to constants."

Any advice?

And i came up with this after reading the help file, and searching the forums, so please dont just send me back to that help file page

Thanks in advance!

That's not how you pass the command line params, $CmdLine is a predefined constant, you can't assign a value to it in the way shown in those scripts, you pass them by running the compiled version of your script something like Run(@ScriptDir & "program.exe /f").

If $CmdLine[0] > 0 then MsgBox(0,'',$CmdLine[1])


Things that I've done..

Icon Resource Editor: icon resource editor 

AutoIt Piano: a piano

AutoIt Unlocker: unlocks files when you want to delete them

Colorful tooltips: a wrapper for the tool tips UDF

Rouge GoogleBot: a full screen animation

ASciTE text editor: a text editor written in autoit

Warning: Posts by this user are subject to change or may disappear without notice.

Share this post


Link to post
Share on other sites

To test you can set the parameters in SciTE (Shift+F8) and then run the script using F5.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Ok, Im really lost now...

my problem is that i was telling $cmdline[0] how many params it was allowed to be?

so if i send 14 different params to the exe $cmdline[0] is automatically set to 14? and $cmdline[x>0] goes to whatever param i put in at that position?

Share this post


Link to post
Share on other sites

so if i send 14 different params to the exe $cmdline[0] is automatically set to 14? and $cmdline[x>0] goes to whatever param i put in at that position?

Correct, correct.

But make sure that x is <= $cmdline[0] when checking the parameters.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

thanks guys. again, I have made things WAYYYY harder than they need to be.... why do i always do this to myself? see my earlier pose about InputBox()...

Share this post


Link to post
Share on other sites

As I'm sure you wont't make a "mistake" twice your coding improves over time (that happend to most of us here) ;)


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

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