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
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