|
-
July 17th, 2003, 02:22 PM
#1
shell function
I am trying to use the shell function to call an executable. I need to allow the executable to finish before continuing processing, is there some way to do this? If I put a breakpoint in my code after the shell function the executable has time to finish and everything works fine. If I take the breakpoint out then it doesn't have time to finish and the executable doesn't work right. What can I do about this? Thanks
~Julian
-
July 17th, 2003, 02:51 PM
#2
The following code will stop furthur code execution until the shell has completed. This example maps an O:\ drive persistently. JUst susstitue your .exe on the "ProcessID = Shell..." line.
'Declare in module
'**********************************************************************
' To run Shelled program asynchronously
Public Declare Function OpenProcess Lib "Kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Public Declare Function WaitForSingleObject Lib "Kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
Public Const SYNCHRONIZE = &H100000
Public Const INFINITE = &HFFFF
'*********************************************************************
Function NetUse(ByVal pathname As String, windowstyle As Integer) As Boolean
' This function is used to map everyone to the new O drive path persistently
Dim ProcessID As Long
Dim ProcessHandle As Long
Dim Path As String
Dim Map
On Error GoTo NetUse_Error
Map = "O: \\163.249.210.37\backup backup12 /user:makecd /PERSISTENT:YES"
ProcessID = Shell("NET USE " & Map, 0)
ProcessHandle = OpenProcess(SYNCHRONIZE, True, ProcessID)
WaitForSingleObject ProcessHandle, INFINITE
NetUse = True
Exit Function
ExitFunction:
Exit Function
NetUse_Error:
NetUse = False
Resume ExitFunction
End Function
-
July 17th, 2003, 03:05 PM
#3
thanks, that works great :-)
-
July 21st, 2003, 08:26 AM
#4
Hi Julian.
I have the same problem you had using the shell function. I got the function that Cubbie sent to you and tryed to run it but i think i dont know what are the correct sustitutions I have to do in the functions parameters.
I am proceeding as follows:
Shell("MY .EXE ADRESS",0)
AS YOU CAN SEE I AM NOT USING THE MAP STRING CUBBIE USED IN THE FUNCTION.
DO I HAVE TO USE IT?
WHAT ARE THE CORRECT SUSTITUTIONS I HAVE TO DO IN THE MAP STRING?
THANK'S.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|