Results 1 to 12 of 12

Thread: Command line

  1. #1

    Thread Starter
    Fanatic Member SeaHag's Avatar
    Join Date
    Jul 2001
    Location
    Lake Huron
    Posts
    901

    Command line

    How do you work with the command line through VB
    1 way i can think of is batch files?

    And other?
    Seahag

  2. #2
    Frenzied Member sebs's Avatar
    Join Date
    Sep 2000
    Location
    Aylmer,Qc
    Posts
    1,606
    u can use shell

    shell "notepad",True

  3. #3
    vbGrandpa
    Guest
    Enter arguments directly from the Command prompt or from the Run menu.

    Then:

    'Read command line arguments.

    'Place in code.

    'We will read in the entire command line as one string
    '"CmdLine" and separate it into (up to 10)
    'individual strings (Args).

    Dim CmdLine As String
    Dim Textline(1 To 80) as String
    Dim Args(1 To 10) As String
    Dim Beg, I, J As Integer

    CmdLine = Command() 'The "Command" function reads the string from the
    'command line.

    For I = 1 To Len(CmdLine)
    Textline(I) = Mid(CmdLine, I, 1)
    Next I

    For I = 1 To 10
    Args(I) = "" 'Initialize all argumenets to NULL.
    Next I

    'Break the command line down into
    'individual argumants.

    Beg = 1
    For J = 1 To 10
    For I = Beg To Len(CmdLine)
    If Textline(I) = " " Then
    Beg = I + 1
    GoTo IncrementJ
    End If
    Args(J) = Args(J) & Textline(I)
    Next I

    IncrementJ:

    Next J

  4. #4

    Thread Starter
    Fanatic Member SeaHag's Avatar
    Join Date
    Jul 2001
    Location
    Lake Huron
    Posts
    901

    How about the other direction.

    vbGrandpa

    I am confused. What does your code do. and where can i use it?

  5. #5
    vbGrandpa
    Guest
    The code parses the command line into separate string values.

    "Run someprogram.exe 1 2 3 4 5 6"

    Args(1)="1" Args(2)="2"........Args(6)="6"

    The program can then use these values as input.

  6. #6
    Frenzied Member sebs's Avatar
    Join Date
    Sep 2000
    Location
    Aylmer,Qc
    Posts
    1,606
    what vbGrandpa is saying is:

    if you run your program from the command line,
    you can send your program parameters,
    and to read the parameters, well use vbGrandpa's
    code to retrieve them!

    But i think your talking about how to run things from vb !

    is that it?

  7. #7
    Frenzied Member
    Join Date
    Sep 1999
    Location
    Phoenix, az
    Posts
    1,517

    Easier code

    He wants something easy.. so make a program and put this in the starting routine.


    Code:
    dim sCmd as string
    
    sCmd = Command()
    
    msgbox sCmd 'msgbox the command line

  8. #8
    Frenzied Member
    Join Date
    Sep 1999
    Location
    Phoenix, az
    Posts
    1,517
    Isnt that what you need. Just reply... I can get different code, or explain anything.

  9. #9

    Thread Starter
    Fanatic Member SeaHag's Avatar
    Join Date
    Jul 2001
    Location
    Lake Huron
    Posts
    901
    Hello all..

    I thought this would be simple.. but is turning out to be something all so ver new..


    Evan.. I think you on the right trak. I dont understand how to use what u put.

    how (no shell) would you open NotePad.. or use copy c:\my.exe, c:\windows\my.exe

    I know you can make a batch file and run it.. I was looking for a mor direct route?

    Thanks everyone for helping.
    Seahag

  10. #10
    Frenzied Member
    Join Date
    Sep 1999
    Location
    Phoenix, az
    Posts
    1,517
    Oh. You use a API. But... Your still shelling.
    So the point of that.. well there isnt any.

  11. #11

    Thread Starter
    Fanatic Member SeaHag's Avatar
    Join Date
    Jul 2001
    Location
    Lake Huron
    Posts
    901
    Good enough for me.
    I hate typing... and I dont understand API, other than is WORKS..?

    Thanks all

  12. #12
    Frenzied Member
    Join Date
    Sep 1999
    Location
    Phoenix, az
    Posts
    1,517
    There is one api that will execute the program associated with the files.. like you execute a txt file and it will notepad.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width