Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Running batch file in VB 6 - how to see the command being executed ?

Status
Not open for further replies.

vmaruv

Programmer
Joined
Apr 8, 2002
Messages
102
Location
US
Hi, In my VB Program (VB 6) I have to execute a series of DOS commands on click of a cmd button. For this I am writing them to a batch file (run.bat) and executing it.

But I have a question. Is it possible to see the command window while the batch file is executing ? I wish to see the output returned by executing the command. How is it possible with VB6 ? Please help. I would like to know if the commands have been executed successfully if there were any errors.

This is very urgent. Your Advice is greatly appreciated.

Vidya.

CODE :

Private Sub cmdsend_Click()
'Make Varibles
Dim imanroot As String
Dim imandata As String
Dim username As String
Dim password As String
Dim msg1 As String
Dim msg2 As String
Dim msg3 As String
Dim location As String
Dim procid As Integer

'Varible values
location = "c:\run.bat"
root = txtroot.Text
data = txtdata.Text
username = txtusername.Text
password = txtpassword.Text

msg1 = "set ROOT = " + " " + root + " "
msg2 = " set DATA = " + " " + data
msg3 = "modes -u=" + username + " " + "-p=" + password
'Open the file if it exists, if not, create it.
Open location For Output As #1

'Write the messege into the file
Print #1, msg1
Print #1, msg2
Print #1, msg3
Close #1
'Send the file
Shell (location)
End Sub


Private Sub Form_Load()
'Create the file run.bat
Open "c:\run.bat" For Output As #1
Close #1
End Sub



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top