Hi,
Yeh you'll need to use the API CreateProcess and WaitForSingleObject
Here is the code for the module
'Win32 (Kernel32.lib) constants, datatypes and funtions
'(used to create and execute processes).
Public Const K32_INFINITE = &HFFFF 'Infinite Wait period.
Public Const K32_NORMAL_PRIORITY_CLASS = &HB0 'Process priority.
Public Const K32_TRUE = 1 'Kernal value for TRUE flag.
Public Const K32_LOGON_NETCREDENTIALS_ONLY = &H2&
Public Const K32_LOGON_WITH_PROFILE = &H1&
Type STARTUPINFO 'Process start data.
cb As Long
lpReserved As String
lpDesktop As String
lpTitle As String
dwX As Long
dwY As Long
dwXSize As Long
dwYSize As Long
dwXCountChars As Long
dwYCountChars As Long
dwFillAttribute As Long
dwFlags As Long
wShowWindow As Long
lpReserved2 As Long
hStdInput As Long
hStdOutput As Long
hStdError As Long
End Type
Type PROCESS_INFORMATION 'Process information data.
hProcess As Long
hThread As Long
dwProcessId As Long
dwThreadId As Long
End Type
Public Declare Function CreateProcess Lib "kernel32" Alias "CreateProcessA" ( _
ByVal lpApplicationName As String, _
ByVal lpCommandLine As String, _
lpProcessAttributes As Any, _
lpThreadAttributes As Any, _
ByVal bInheritHandles As Long, _
ByVal dwCreationFlags As Long, _
lpEnvironment As Long, _
ByVal lpCurrentDriectory As String, _
lpStartupInfo As STARTUPINFO, _
lpProcessInformation As PROCESS_INFORMATION _
) As Long
Public Declare Function CloseHandle Lib "kernel32" ( _
ByVal hObject As Long _
) As Long
Public Declare Function WaitForSingleObject Lib "kernel32" ( _
ByVal hHandle As Long, _
ByVal dwMilliseconds As Long _
) As Long
********************
And now the code for the execution of the command
Private Function RunShellAsProcess(strShellCmd As String) As Integer
Dim doProc As PROCESS_INFORMATION
Dim doStart As STARTUPINFO
Dim lResult As Long
On Error GoTo ErrH
'Execute the file and wait for execution to complete.
doStart.cb = Len(doStart)
lResult = CreateProcess(vbNullString, strShellCmd, ByVal 0&, ByVal 0&, K32_TRUE, K32_NORMAL_PRIORITY_CLASS, 0&, vbNullString, doStart, doProc)
'Shell (sCmdsFilePath)
'moTextStream.Write (CStr(Now) & ": Run batch file result = " & lResult & vbCrLf)
If lResult = K32_TRUE Then
lResult = CloseHandle(doProc.hThread)
lResult = WaitForSingleObject(doProc.hProcess, K32_INFINITE)
lResult = CloseHandle(doProc.hProcess)
End If
RunShellAsProcess = 0
Exit Function
ErrH:
RunShellAsProcess = -1
End Function
******************
Just call the function RunShellAsProcess passing a shell command to run you virus scan/checker.
Hope this helps,
Mike