Jump to content
Sign in to follow this  

Run autoit script from cmd with option

Recommended Posts

Hi all,

I have the following script, which I am trying to make it possible to run it from a cmd prompt with a flag on the end so it runs under a different manner...


If I double click run.au3 (or run.exe when compiled) it opens notepad.exe maximized.

But if i run it from cmd prompt as "run.au3 /min" or "run.exe /min I want it to change $aflag so it runs the second part of the if else statement.

Does anyone know how I would go abouts this sort of exercise?

Global $aflag = ""
Func Example()

If $aflag = "" Then
    Local $iPID = Run("notepad.exe", "", @SW_SHOWMAXIMIZED)
    Local $iPID = Run("notepad.exe", "", @SW_SHOWMINIMIZED)


Share this post

Link to post
Share on other sites

If $CmdLine[0] <> "" Then
     $aflag = $CmdLine[1]
     $aflag = ""

That's the basics of it, that you can put at the start of your script.

I would read up about it though.

You also need to do your own additional testing for "/min"

P.S. I was sure they had an example like that in the Help file etc, but it seems to have been modified and removed, which doesn't make it easy for a beginner.

Edited by TheSaint

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.


What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)


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  

  • Create New...