Reputation: 49
Okay so ive got another one, Right now im working on a button, called installbtn in code.
Right now i have in my code.
private void installbtn_Click(object sender, EventArgs e)
{
// Access the internal exe resource pcc - the pcc is Path Copy Copy, which i am using as a
// requirement to use this software
byte[] pccFile = Properties.Resources.pcc;
// The resource pcc.exe as a binary called pcc which is then used as a byte called pccFile
string pccExe = Path.Combine(Path.GetTempPath(), "pcc.exe");
// The Executable and its filename + Extenstion
using (FileStream exeFile = new FileStream(pccExe, FileMode.Create))
exeFile.Write(pccFile, 0, pccFile.Length);
// Write the file to users temp dir
Process.Start(pccExe);
// Start the Installer
installbtn.Text = "Installing...";
StatusLabel1.Text = "Installing PCC Now...";
// Indicate on the form, the current process status.
// Here i want the application to check if pccExe has closed
// after the user has installed the component and its process "pcc.exe" exits
MessageBox.Show("Module Installed /r/nPlease Start the Application", "Application Module Installed");
installbtn.Text = "Restart Now!";
StatusLabel1.Text = "Please Restart the Application";
// and if it has then show a message box and reflect in the form
// i want it to quit and restart the application after the message box is closed
}
now when the installer finishes, i would like to be able to detect when the installer closes ("pcc.exe")
after install and then reload the application once it has. Not sure if its possible but i would appreciate the help.
Thanks Shaun.
Upvotes: 1
Views: 949
Reputation: 8902
You could use Process.WaitForExit()
The WaitForExit() overload is used to make the current thread wait until the associated process terminates. This method instructs the Process component to wait an infinite amount of time for the process and event handlers to exit
Process process = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo();
process.StartInfo = startInfo;
startInfo.FileName = exeToRun;
process.Start();
process.WaitForExit();
Upvotes: 4
Reputation: 6608
Start
returns a Process
object, on which you can wait (or start a thread that waits, etc.).
Upvotes: 0