?
Solved

Conformation after Shell process finished...

Posted on 2000-03-15
3
Medium Priority
?
246 Views
Last Modified: 2010-05-02
I open standard executable file with Shell function from another application and I want  to receive conformation after executable finished all the auto processes in order to start next executable. Is there any other way besides creating new dll to manage everything?

0
Comment
Question by:GinaP
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 20

Expert Comment

by:hes
ID: 2621581
Place this in the declarations section of the project.

Private Type STARTUPINFO
    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 Integer
    cbReserved2 As Integer
    lpReserved2 As Long
    hStdInput As Long
    hStdOutput As Long
    hStdError As Long
End Type

Private Type PROCESS_INFORMATION
    hProcess As Long
    hThread As Long
    dwProcessID As Long
    dwThreadID As Long
End Type

Private Declare Function WaitForSingleObject Lib _
"kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds _
As Long) As Long

Declare Function CreateProcessA Lib "kernel32" _
(ByVal lpApplicationName As Long, ByVal lpCommandLine As _
String, ByVal lpProcessAttributes As Long, ByVal _
lpThreadAttributes As Long, ByVal bInheritHandles As Long, _
ByVal dwCreationFlags As Long, ByVal lpEnvironment As Long, _
ByVal lpCurrentDirectory As Long, lpStartupInfo As _
STARTUPINFO, lpProcessInformation As PROCESS_INFORMATION) _
As Long

Declare Function CloseHandle Lib "kernel32" (ByVal hObject _
As Long) As Long

Private Const NORMAL_PRIORITY_CLASS = &H20&
Private Const INFINITE = -1&



In your code:

Dim proc As PROCESS_INFORMATION
Dim start As STARTUPINFO

'Initialize the STARTUPINFO structure:
start.cb = Len(start)

'Start the shelled application:
ret& = CreateProcessA(0&, "Your Batch File", 0&, 0&, 1&, _
NORMAL_PRIORITY_CLASS, 0&, 0&, start, proc)

'Wait for the shelled application to finish:
ret& = WaitForSingleObject(proc.hProcess, INFINITE)
ret& = CloseHandle(proc.hProcess)
0
 
LVL 14

Accepted Solution

by:
wsh2 earned 140 total points
ID: 2621602
Yes.. what you want to do is a shell and wait.. ie.. run the program and wait until it is done until you continue processing. If you have VB6 and the "Windows Scripting Host" (it comes with Explorer" do the following:

1. Create a Standard.Exe Project.
2. Add a Project reference (Click on VB Menu.. Project.. References).. to "Windows Scripting Host Object"
3. Copy and paste the code below into the Form1 code window.
4. Change the strCommand variable below to the program you want to execute (its set for c:\windows\calc.exe for demo purposes)
5. Give it a run.. calc will open.. when you close it.. the program will continue.. <smile>.

<----- Code Begin ----->

Option Explicit
Const SW_HIDE = 0
Const SW_SHOWNORMAL = 1
Const SW_SHOWMINIMIZED = 2
Const SW_SHOWMAXIMIZED = 3
Const SW_SHOWNOACTIVE = 4
Const SW_SHOW = 5
Const SW_MINIMIZE = 6
Const SW_SHOWMINNOACTIVE = 7
Const SW_SHOWNA = 8
Const SW_RESTORE = 9

Private Sub Form_Load()

  Dim strCommand As String
  strCommand = "c:\windows\calc.exe"

  Dim booWaitToFinish
  booWaitToFinish = True

  MsgBox ("About to run " & strCommand)

  Dim oShl As New IWshShell_Class
  Call oShl.Run(strCommand, SW_SHOWNORMAL, booWaitToFinish)
   
  Msgbox (strCommand & " COMPLETED!!!")

End Sub

<----- Code End ----->





0
 

Author Comment

by:GinaP
ID: 2623592
Thank you very much, wsh2. The answer is perfect. It works.
I appreciated the other answer also, just this one seems little simpler and shorter.
Thanks again.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month10 days, 15 hours left to enroll

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question