|
-
Sep 16th, 2009, 05:26 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Pause application until process finished
I've spent the last two hours trying to figure this one out,but no luck.
Basicly it's pretty simple.When a button is clicked,my program gets the list of all Drives on a current computer.
Then I use String.Concat to merge the drive letter and the rest of the path.
So I get something like: "C:\" + "somefolder\somefile.some_extension"
That creates a full path to a file I am looking for.Then I check if that file exists.If it doesn't exist,I use Process.Start to run the setup file(to install the program I need).
It works well and installs the program I need.
The Problem:
I want my application,after the installation is finished,to check again if the program is installed and ofcourse confirm that it is.
This is my code:
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim DriveList As String() = Directory.GetLogicalDrives()
Dim Drive, FullPath, Path1 As String
Dim EmptyDrives As Integer
Path1 = "wamp\wampmanager.exe"
EmptyDrives = 0
For Each Drive In DriveList
FullPath = String.Concat(Drive, Path1)
If File.Exists(FullPath) Then
MsgBox("Wamp server is installed and can be found at: " & FullPath)
Exit Sub
Else
EmptyDrives = EmptyDrives + 1
If Directory.GetLogicalDrives.Count = EmptyDrives Then
Dim AppPath As String
AppPath = My.Application.Info.DirectoryPath
If MsgBox("We could not detect Wamp server on this machine!" & vbNewLine & "Would you like to install Wamp Server now?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
Process.Start(AppPath & "\WampServer20h.exe")
End If
End If
End If
Next Drive
End Sub
-
Sep 16th, 2009, 05:33 PM
#2
Re: Pause application until process finished
Replace this line:
Code:
Process.Start(AppPath & "\WampServer20h.exe")
With this:
Code:
Process.Start(AppPath & "\WampServer20h.exe").WaitForExit()
Then your app will block on that line until the process exits. Ideally you would do this in a background thread so that your application's user interface does not freeze but that may not matter that much in your case, I dont know.
PS instead of using String.Concat to combine file paths, you can use the 'proper' method which is IO.Path.Combine
-
Sep 17th, 2009, 03:50 AM
#3
Thread Starter
Hyperactive Member
Re: Pause application until process finished
Thank you,it works!
Resolved!
-
Sep 17th, 2009, 04:06 AM
#4
Re: Pause application until process finished
No problem dont forget to mark the thread as resolved by using the Thread Tools menu at the top of the first post
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
|