How do you work with the command line through VB
1 way i can think of is batch files?
And other?
Seahag
Printable View
How do you work with the command line through VB
1 way i can think of is batch files?
And other?
Seahag
u can use shell
shell "notepad",True
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
vbGrandpa
I am confused. What does your code do. and where can i use it?
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.
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?
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
Isnt that what you need. Just reply... I can get different code, or explain anything.
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
Oh. You use a API. But... Your still shelling.
So the point of that.. well there isnt any.
Good enough for me.
I hate typing... and I dont understand API, other than is WORKS..?
Thanks all
There is one api that will execute the program associated with the files.. like you execute a txt file and it will notepad.