<Do you know how to CALL the Command Prompt window and send <commands to it?<br>
<and Close it too afterwords?<br>
<br>
Option Explicit<br>
<br>
Private Declare Function AllocConsole Lib "kernel32" () As Long<br>
Private Declare Function GetStdHandle Lib "kernel32" (ByVal nStdHandle As Long) As Long<br>
Private Declare Function WriteConsole Lib "kernel32" Alias "WriteConsoleA" (ByVal hConsoleOutput As Long, ByVal lpBuffer As String, ByVal nNumberOfCharsToWrite As Long, lpNumberOfCharsWritten As Long, lpReserved As Any) As Long<br>
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long<br>
Private Declare Function FreeConsole Lib "kernel32" () As Long<br>
<br>
Private Const STD_OUTPUT_HANDLE = -11&<br>
<br>
Private hConsole As Long<br>
<br>
Private Sub Form_Load()<br>
Dim txt As String<br>
Dim num_written As Long<br>
<br>
If AllocConsole() Then<br>
hConsole = GetStdHandle(STD_OUTPUT_HANDLE)<br>
If hConsole = 0 Then MsgBox "Couldn't allocate STDOUT"<br>
<br>
' Present a warning.<br>
txt = "******************************************" & vbCrLf & _<br>
"* Warning: Do not close this window! *" & vbCrLf & _<br>
"* Close the VB program's window instead. *" & vbCrLf & _<br>
"******************************************" & vbCrLf<br>
WriteConsole hConsole, txt, Len(txt), num_written, vbNullString<br>
<br>
' Make this form visible and on top.<br>
Me.Show<br>
SetFocus<br>
Else<br>
MsgBox "Couldn't allocate console"<br>
End If<br>
End Sub<br>
<br>
a CommandButton with :<br>
<br>
Private Sub Command1_Click()<br>
Dim app_name As String<br>
Dim txt As String<br>
Dim num_written As Long<br>
<br>
app_name = App.Path<br>
If Right$(app_name, 1) <> "\" Then app_name = app_name & "\"<br>
app_name = app_name & "test.bat"<br>
<br>
txt = "Ready to run" & vbCrLf<br>
WriteConsole hConsole, txt, Len(txt), num_written, vbNullString<br>
Shell app_name<br>
End Sub<br>
<br>
Private Sub Form_Unload(Cancel As Integer)<br>
CloseHandle hConsole<br>
FreeConsole<br>
End Sub<br>
<br>
<br>
<p>Eric De Decker<br><a href=mailto:vbg.be@vbgroup.nl>vbg.be@vbgroup.nl</a><br><a href= Center :
Visual Basic Center</a><br>