Tim-

Sunday, March 16, 2003, 5:20:44 PM, you wrote:

TM> I don't think there are any properties to affect this... Anyone know of
TM> any?

I don't think you can do this directly in a .bat file. When I have to
check for the existence of a dos window I write some code to call the
Windows API. Here's a VBA sample from MSAccess which will *probably*
work in the Windows scripting host. In this example "xcp" is the name
of the batch file that was launched "xcp.bat" (it's in the "Finished -
xcp" string). Personally I'd rather write a CLI program in C to handle
it, but this should do the trick without having to break out the
compiler.

'  ==============================
Private Declare Function FindWindow Lib "user32.dll" _
        Alias "FindWindowA" _
        (ByVal lpClassName As String, _
        ByVal lpWindowName As String) As Long

Private Declare Function SendMessage Lib "user32.dll" _
        Alias "SendMessageA" _
        (ByVal hWnd As Long, _
        ByVal Msg As Long, wParam As Any, lParam As Any) As Long

Private Type OSVERSIONINFO
  dwOSVersionInfoSize As Long
  dwMajorVersion As Long
  dwMinorVersion As Long
  dwBuildNumber As Long
  dwPlatformId As Long
  szCSDVersion As String * 128
End Type

'  ==============================
'  IsNT
'  ==============================
'
' Return a boolean showing whether the current OS is an NT version
Public Function IsNT() As Boolean
    On Error GoTo ErrorHandler
    Dim lngOSVersion  As Long
    Dim lpVersionInformation As OSVERSIONINFO
    Const kPlatformWin32s As Integer = 0    'Windows 3.1 (gasp, cough, cough)
    Const kPlatformWin95 As Integer = 1     'Windows 95 or 98
    Const kPlatformNT As Integer = 2        'Windows NT, 2k, XP
   
    IsNT = False    ' default to a non-NT operating system
    ' Let's see what OS we're running under
    lpVersionInformation.dwOSVersionInfoSize = Len(lpVersionInformation)  ' set the 
size of the structure
    lngOSVersion = GetVersion(lpVersionInformation)
    If (kPlatformNT = lpVersionInformation.dwPlatformId) Then
        ' if we're running on an NT (win2k, XP) platform
        IsNT = True
    End If
    GoTo Cleanup

ErrorHandler:
Cleanup:
End Function

'  ==============================
    Dim strDOS As String
    Dim lngProcessHandle   As Long

    ' Let's see what OS we're running under
    If IsNT() Then
        ' if we're running on an NT (win2k, XP) platform
        strDOS = "C:\WINNT\System32\cmd.exe"
    Else
        ' must be win95 or win98
        strDOS = "Finished - xcp"
    End If
    
    lngProcessHandle = FindWindow(vbNullString, strDOS)
    If (0 = lngProcessHandle) Then  ' if it doesn't exist
        Do While (0 = lngProcessHandle) ' wait for it to appear
            lngProcessHandle = FindWindow(vbNullString, strDOS)
        Loop
    End If
    
    If IsNT() Then
        Do While (0 <> lngProcessHandle) ' wait for it to go away
            lngProcessHandle = FindWindow(vbNullString, strDOS)
        Loop
    Else
        ' Close the MSDOS Prompt window : DestroyWindow() won't work here.
        SendMessage lngProcessHandle, WM_CLOSE, 0, 0
    End If
'  ==============================

-Mark Wieder

 Using The Bat! v1.63 Beta/7 on Windows 2000 5.0 Build 2195 Service Pack 2
-- 


________________________________________________________
 Current version is 1.61 | "Using TBTECH" information:
http://www.silverstones.com/thebat/TBUDLInfo.html

Reply via email to