Sign in to follow this  
Followers 0
Steven Vandenhoute

start program with /...

14 posts in this topic

Can somebody give me some help on this isue.

I want to start my program with some options (like this: program/start)

How can I program this in my program?


"You cannot solve a problem with the mind that created it" (Albert Einstein)

Share this post


Link to post
Share on other sites



Lookup command line options in the help file.



Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post


Link to post
Share on other sites

can i use my own command

how can i code that


"You cannot solve a problem with the mind that created it" (Albert Einstein)

Share this post


Link to post
Share on other sites

I think you've all misunderstand me (maybe my own fault)

What I want is the following:

for an example. you can run the command copy with some parameters like copy /y etc

i want to code something in my autoit script so i can run my compiled script also with some parameters (defined by me)

I know I have seen that piece of code somewhere, but I can't find it anymore


"You cannot solve a problem with the mind that created it" (Albert Einstein)

Share this post


Link to post
Share on other sites

Check out command line parameters in the helpfile.

Thx to you all.

I've found the sollution.

It was indeed with the command line parameter. But the first thing I felt when reading the help file was... WTF I don't get it.

But I found a way to get it.

The code I wrote

if $CmdLine[0]<1 Then
        MsgBox(0,"Parameters", "/to and /from")
    Exit
    Else


If $CmdLine[1] = "to" Then
    
    Run("d:\fujitron\brestos4_BO\Brestos4_BO.exe /AB_TOKASSA_COM", "", @SW_MAXIMIZE)
    
    
    MsgBox(0,"","File saved to kassa",2)
    
Else
    
If $CmdLine[1] = "from" Then    
    Run("d:\fujitron\Brestos4_BO\brestos4_BO.exe /AB_FROMKASSA_COM", "", @SW_MAXIMIZE)
    
    MsgBox(0,"", "File saved from kassa",2)
    


    
Else

    Exit

    

EndIf
EndIf
EndIf

It works, but if anybody can write it in another way, please tell me ( I still want to learn)


"You cannot solve a problem with the mind that created it" (Albert Einstein)

Share this post


Link to post
Share on other sites

If statements certainly work, but if you have a lot of switches, Select...Case will probably look better.

If you have SciTe (and why wouldn't you? ;) ) you can enter Ctrl-Shift-R, enter or select "cmdlineselect" and get this structure inserted into your script:

If $Cmdline[0] Then
    For $i = 1 To $Cmdline[0]
        Select
            Case $Cmdline[$i] = '/?'
                MsgBox(0x40000, StringTrimRight(@ScriptName, 4) & ' Help', _
                        'Switches are:' & @LF _
                         & @LF & '/extract' _
                         & @LF & @TAB & 'Extract files to current directory' _
                         & @LF & '/x' _
                         & @LF & @TAB & '' _
                         & @LF & '/x' _
                         & @LF & @TAB & '' _
                         & @LF & '/x' _
                         & @LF & @TAB & '' _
                         & @LF & '/x' _
                         & @LF & @TAB & '' _
                         & @LF & '/x' _
                         & @LF & @TAB & '')
                Exit
            Case $Cmdline[$i] = '/extract'
                FileInstall('?', @ScriptDir & '')
                Exit
            Case $Cmdline[$i] = '/x'
            Case $Cmdline[$i] = '/x'
            Case $Cmdline[$i] = '/x'
            Case $Cmdline[$i] = '/x'
            Case $Cmdline[$i] = '/x'
            Case Else
                MsgBox(0x40000, 'Incorrect switch used', 'Command used:' & @LF & $CmdlineRaw _
                         & @LF & @LF & 'Use /? for the switches available.')
                Exit
        EndSelect
    Next
EndIfoÝ÷ Ø   趫¦nªðk*ºÈ§Ê&©Ý)Þ³­r¬Ëhmæëh©Ýë(ëax%Gªº¶)¢ëyÓJ®¢Ú'¶¢iÙbæ§v­¶¯j[çM"Ú½ªâi¹^N¬²ÚîrÛ«{¥W­Ê¢ØZµ«­¢+Ù%ÀÌØí
µ1¥¹lÁtÐìÄQ¡¸(%½ÈÀÌØí¤ôÈѼÀÌØí
µ1¥¹lÁt($%%MÑÉ¥¹%¹MÑÈ Ìäì½Ñ¥µ½ÕÑðµÑ¥µ½ÕÑð½ÑðµÐÌäì°ÀÌØí
µ1¥¹lÀÌØí¤´Åt¤Q¡¸($$$ÀÌØíÑ¥µ½ÕÐôÀÌØí
µ1¥¹lÀÌØí¥t($%¹%(%9áÐ)¹%

BlueBearrOddly enough, this is what I do for fun.

Share this post


Link to post
Share on other sites

Thx Bluebearr

this is helping.

First I want to thank you for giving me the tip to use ctrl-shift-R.

I didn't know that excist.

Now I can modifie everything.

Thank you


"You cannot solve a problem with the mind that created it" (Albert Einstein)

Share this post


Link to post
Share on other sites

Thx Bluebearr

this is helping.

First I want to thank you for giving me the tip to use ctrl-shift-R.

I didn't know that excist.

Now I can modifie everything.

Thank you

If you're going to do it with $CmndLine (as shown in help) or even from the run dialog I strongly recommend that you NOT use '/' as the separator for Commandline parameters. Microsoft is very soon ( I think in Vista) dropping that as a separator in favor of '-' which already works in most cases.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

well, that is strange

in my example, I didn't hardcoded something like /? but only the ? and it works

In the other examples given by other users the /? is fully hardcoded.

What is the best thing? Do I need to leave the / or not?


"You cannot solve a problem with the mind that created it" (Albert Einstein)

Share this post


Link to post
Share on other sites

well, that is strange

in my example, I didn't hardcoded something like /? but only the ? and it works

In the other examples given by other users the /? is fully hardcoded.

What is the best thing? Do I need to leave the / or not?

Sometimes Yes, sometimes No. In your case No because if you run a command (don't confuse with file) and you have an invalid switch then it will usually default to "/?"

To follow your example it would actually be

RunWait(@Comspec & " copy /?)

Read about @Comspec in the help file under "Run"


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

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