Kathy
you could try the shellwait function
(not fully tested)
RetVal = Shell("command.com /c nbtstat -a " & sMachineID , 0)
based on the snippet of code that does/did work:
RetVal = Shell("command.com /c nbtstat -a " & sMachineID & " > " &
Environ$("temp") & "\" & sMachineID & ".txt", 0)
hth
Tim
the shellwait code is reproduced below incl a dummy test (put code in its
own module for convenience):
Option Explicit
Private Const PROCESS_QUERY_INFORMATION As Long = &H400
Private Const STILL_ACTIVE As Long = &H103
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess
As _
Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function GetExitCodeProcess Lib "kernel32" (ByVal hProcess
As _
Long, lpExitCode As Long) As Long
Sub TestShellAndWait()
Dim Ret_Val_
ShellAndWait ("command.com /c dir s: > c:\temp\junk.txt")
'ShellAndWait ("command.com dir c:\*.* > c:\temp\junk.txt")
End Sub
''' Arguments: szCommandLine The command line to execute using Shell.
''' iWindowState (Optional) The window state parameter to
pass
''' to the Shell function. Default = vbHide.
''' See Shell function help for other options.
Sub ShellAndWait(ByVal szCommandLine As String, Optional ByVal iWindowState
As _
Integer = vbHide)
Dim lTaskID As Long
Dim lProcess As Long
Dim lExitCode As Long
Dim lResult As Long
''' Run the Shell function.
lTaskID = Shell(szCommandLine, iWindowState)
''' Get the process handle from the task ID returned by Shell.
lProcess = OpenProcess(PROCESS_QUERY_INFORMATION, 0&, lTaskID)
''' Loop while the shelled process is still running.
Do
''' lExitCode will be set to STILL_ACTIVE as long as the shelled
process is running.
lResult = GetExitCodeProcess(lProcess, lExitCode)
DoEvents
Loop While lExitCode = STILL_ACTIVE
End Sub