# Solved: Wait for process to finish loading before killing it (visual basic 2005)



## new tech guy (Mar 27, 2006)

Hello folks,
Sorry if my title sounds a little confusing but right now i am working on a visual basic script for launching microsoft office onenote 2007. I have a specific way of launching it and shutting it down so i have the onenote tray icon when the application is running but it dissappears when turned off. I have shutdown already figured out and all of its problems are resolved however i seem to come across trouble getting a working startup as what i need to do is launch the tray icon application which in turn launches the main program but not in its main window (opens a side note) so then i have the script kill the main process which closes that window then launch the process again for the main program so that the program opens in its main window. The trouble i run into is that if i leave the script in its current state, it seems everything fires off premautrely where it will launch through the processes before onenotem and onenote originally get a chance to load into memory and i will just wind up with the main window of onenote. So what im asking is if there is a way to put the launch program into a loop or some sort of sleep that will wait until the original launch of onenotem is complete with its pairing onenote process before starting onenote. I have googled and so far i have seen that c++ has a process.wait command that will wait until the process is complete and idle before continuing. To that end, here is what i have so far, i know it has no delay yet but that is all it is really missing.



CODE said:


> Sub Main()
> 'Write a message to the screen notifying the user exactly what our application is doing
> Console.WriteLine("Launching Microsoft Office Onenote 2007, please wait...")
> 
> ...


----------



## new tech guy (Mar 27, 2006)

Nevermind, fixed it with a batch script after i found how the autostart of the icon works without showing the onenote window which is through a few command switches.


----------

