qwertyuiopasdfghjkl
asked on
dos command
can i write a program in vb to execute dos command ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
' 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
ASKER
then how to capture the result return from ms-dos ? and send the command again ?
tip:
make the result a file.
try this:
c:\dir > my-dir.txt
now look at the file my-dir.txt with notepad.
make the result a file.
try this:
c:\dir > my-dir.txt
now look at the file my-dir.txt with notepad.
AppActivate MyApp