Search - Articles
DevASP.NET for ASP.NET, VB.NET, XML and C# (C-Sharp) Developers Tuesday, March 03, 2009
Dev Articles
Search Directory
ASP.NET
VB.Net
C-Sharp
SQL Server
 

FREE 12 month online training for ASP.NET & MS Expression Studio and a Free copy of MS Expression Web with Windows Server Purchase
working with other application using System.Diagnostics.Process Name Space in VB.net 2.0.

Author: Zunnair

In this article i will show you how you can call multiple applications from Your own application by clicking once using VS.Net.

Create New Project in VB.net.and place three Button control from tool box  are Used just for practice Sake and place on form having text calculator,,notepad, paint...

 

 Now write  that function against the click event of your first function .click event is generated by double clicking on Button.write that function as written below.

VB.Net

 

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim p As New System.Diagnostics.Process

        p.StartInfo.FileName = "Calc.exe"

        p.Start()

End Sub

 

 

C#.Net

private void Button1_Click(object sender, System.EventArgs e)

{

    System.Diagnostics.Process p = new System.Diagnostics.Process();     p.StartInfo.FileName = "Calc.exe"; 

    p.Start();

}

 

 

 

In that function first we create the instance of  System.Diagnostics.Process class and after that assigns the value of StartInfo.FileName by your executable file.and after that just start your file.

 

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

        Dim p As New System.Diagnostics.Process

        p.StartInfo.FileName = "Notepad.exe"

        p.Start()

End Sub

 

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click

   Dim p As New System.Diagnostics.Process

   p.StartInfo.FileName = "Mspaint.exe"

   p.Start()

End Sub

 

  1. private void Button2_Click(object sender, System.EventArgs e)
  2. {
  3.    
  4.     System.Diagnostics.Process p = new System.Diagnostics.Process();
  5.    
  6.     p.StartInfo.FileName = "Notepad.exe";
  7.    
  8.     p.Start();
  9.    
  10. }
  11. private void Button4_Click(object sender, System.EventArgs e)
  12. {
  13.    
  14.     System.Diagnostics.Process p = new System.Diagnostics.Process();
  15.    
  16.     p.StartInfo.FileName = "Mspaint.exe";
  17.    
  18.     p.Start();
  19.    
  20. }

 

After that in the end to close all applications with your application close event we use same namespace Kill Method by calling that event all application processing Kill

 

Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing

        p.Kill()

End Sub

 

C#.Net

private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)

{

p.Kill();    

}

 

This is a simple article .i hope u will like and enjoying this Article. If you feel any difficulty then reference the source code.because Source code is given with this Article for your proper understanding.

   
Add Article Comment:
Name :
Email Address :
   
Comments :
 
   
<< Working with Delegates in VB.Net

Disclaimer - Privacy
© 2002-2014 DevASP.net