hi all,
I have a function that will execute a shell function. To avoid the following statement being executed before the shell command completed, i've used WaitForSingleObject function. The codes are working fine. However, i need to close the command prompt window after the shell function completed in order to execute the following command. My question is, how can i automatically close the command window once the shell function is executed completely?
Below are my codes :
Function Uploadfile(file As String)
source = DataFilePath & file
destination = DupFilePath & "text1.txt"
Set fso = CreateObject("Scripting.FileSystemObject"
fso.copyfile source, destination
'codes added in to make sure shell command finish
'executing before the following command being called.
lngExecOK = Shell(BatFilePath & "text1.bat"
'handle to process
lProcessHandle = OpenProcess(&H100000, True, lngExecOK)
'Wait
lReturnValue = WaitForSingleObject
(lProcessHandle,INFINITE)
Uploadfile = lReturnValue
' i need to close the Dos prompt window in order
' to execute the following line of codes.
fso.deletefile (destination)
End Function
I have a function that will execute a shell function. To avoid the following statement being executed before the shell command completed, i've used WaitForSingleObject function. The codes are working fine. However, i need to close the command prompt window after the shell function completed in order to execute the following command. My question is, how can i automatically close the command window once the shell function is executed completely?
Below are my codes :
Function Uploadfile(file As String)
source = DataFilePath & file
destination = DupFilePath & "text1.txt"
Set fso = CreateObject("Scripting.FileSystemObject"
fso.copyfile source, destination
'codes added in to make sure shell command finish
'executing before the following command being called.
lngExecOK = Shell(BatFilePath & "text1.bat"
'handle to process
lProcessHandle = OpenProcess(&H100000, True, lngExecOK)
'Wait
lReturnValue = WaitForSingleObject
(lProcessHandle,INFINITE)
Uploadfile = lReturnValue
' i need to close the Dos prompt window in order
' to execute the following line of codes.
fso.deletefile (destination)
End Function