|
-
Apr 10th, 2001, 10:41 AM
#1
Thread Starter
Addicted Member
-
Apr 10th, 2001, 10:48 AM
#2
Hyperactive Member
A few weeks ago I've had the same problem. I had found a tip on this site, I'll see if I can find it again.
Till then.
-
Apr 10th, 2001, 10:55 AM
#3
Thread Starter
Addicted Member
i assume i get the application id of the program i just ran, and wait for that id to dissapear, problem is, i dont know where to start.
-
Apr 10th, 2001, 11:11 AM
#4
Hyperactive Member
Write a separate module:
code:
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&
Private Const STARTF_USESHOWWINDOW = &H1
Public Enum enSW
SW_HIDE = 0
SW_NORMAL = 1
SW_MAXIMIZE = 3
SW_MINIMIZE = 6
End Enum
Public Sub ExecCmd(cmdline$)
Dim proc As PROCESS_INFORMATION
Dim start As STARTUPINFO
'Initialize the STARTUPINFO structure:
start.cb = Len(start)
'start.dwFlags = STARTF_USESHOWWINDOW
'start.wShowWindow = SW_MAXIMIZE
'Start the shelled application:
ret& = CreateProcessA(0&, cmdline$, 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)
End Sub
and to start your programm:
Call ExecCmd(your_program_name)
I couldn't find the article this fast, but I copied the code
good luck, if you have any questions, just ask me.
-
Apr 10th, 2001, 11:12 AM
#5
Thread Starter
Addicted Member
thanks, i'll give it a go
-
Apr 10th, 2001, 04:50 PM
#6
Member
I have tried the previous code snippet and had no luck with it. I am looking for something myself
-
Apr 11th, 2001, 01:50 AM
#7
How about this?
When u start an app, it goes to the top of the Zorder! How about you obtain the apps name thru the GetWindowText API call, then run a timer every 2.5 secs or so and check if it is still running! if it is, the timer will keep goin until the app is closed. then include some code to get ur program to resume where it left off! sounds complex, it is! but i have done it be4, unfortunately i lost the code when i formatted!
-
Apr 11th, 2001, 06:03 AM
#8
Hyperactive Member
-
Apr 11th, 2001, 06:06 AM
#9
Thread Starter
Addicted Member
i have/am using the code and it is doing everything that i need it to.
it is only being used to run some batch files.
-
Apr 11th, 2001, 10:17 PM
#10
Member
Starting an App
I am attempting to perform an unattended install of a remote PC from a CD. I need my VB app to script all needed software installs silently and in the background. However, I have been unable to accomplish the small feat of waiting the for the shelled process to complete prior to continuing on with the next step. If anyone has any suggestions or can fix the above mentioned code snippett it would be greatly appreciated.
Thanks
-
Apr 12th, 2001, 03:09 AM
#11
Hyperactive Member
Can you describe your problem with the code I provided? Do you get an error, is the code running but doesn't perform the action requested, where does the problem appear etc. ?
-
Apr 12th, 2001, 07:20 AM
#12
Member
There really isn't anything to report. When I use the code A) nothing happens B) It can't create a new WOW session. I did a little research on my own and found that you need to specfiy the constant 'CREATE_SEPARATE_WOW' and adjust the security attributes. However I have been unsuccessful. It appears some the application setups that I am attempting to run are 16bit and this function wont' run them.
Everyone!!! Can I have your attention please?
Sit back, Relax and watch the world unfold before your very eyes.
Mystical isn't it, oh well I tried!!!
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
|