dos command

can i write a program in vb to execute dos command ?
qwertyuiopasdfghjklAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
twardConnect With a Mentor Commented:
Check out the Shell Command or the ShellExecute API call.
0
 
cameron2Commented:
MyApp shell("C:\Windows\Command.com" , 1)
AppActivate MyApp
0
 
a111a111a111Commented:
Here is a complete answer:


' this part in your general decleration
'------- start here  ------------

option Explicit
                  Dim ret3&
                  Private Declare Function ShellExecute Lib "shell32.dll" Alias _
                      "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As _
                       String, ByVal lpFile As String, ByVal lpParameters As String, _
                      ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
                    ' shayplace@hotmail.com or visit the home page  http://www.hili.com/~shay

'------ end general decleration --------


'place this code in your form

'--------- code start here -------

Private Sub cmdRunCalculator_Click()
                  ' Run any program EXE,COM from here.
                  ret3& = ShellExecute(Me.hwnd, "Open", "calc.exe", "", App.Path, 1)
                  End Sub

'--- code end here ---

if you need more help get the complete source code and sample from: http://www.hili.com/~shay/link/vbexamples.htm



0
 
qwertyuiopasdfghjklAuthor Commented:
then how to capture the result return from ms-dos ? and send the command again ?
0
 
a111a111a111Commented:
tip:

make the result a file.

try this:

c:\dir > my-dir.txt

now look at the file my-dir.txt with notepad.


0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.