Small Project on Accessing Windows System EXE's and any 3rd Pary Softwares through Windows Application

Raj.Trivedi
Posted by in C# category on for Beginner level | Points: 250 | Views : 3066 red flag

Hello Team,

In this article we will see how we can call windows exe from Windows Application or any 3rd Party Installed Software on a Button Click

Introduction

Hello Friends,

Today in this article we will see how we can access windows operating system exe's and any installed S/W in the PC.

In this article we will be accessing 

Windows EXE

  1. Notepad
  2. Windows Media Player
  3. Sound Recorder

3rd Party Apps

  1. MS Word
  2. Irfan View (Free Ware Software)
  3. MS Excel

Objective

Understanding how does the Shell Command of VB.NET works in C Sharp.

In VB.NET to open any Installed application we used Shell Command but in C Sharp the Shell Command does not work for that we use a Reference provided i.e. System.Diagnostics and using it Process.Start Method.





Using the code


The Process.Start Method of the System.Diagnostic Library allows us to run the exe's installed in the PC.

It works well for any Apps even any 3 rd Party Software.


The Process.Start requires the Path where the exe is placed in the computer as a Parameter.

// Code Behind
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;

namespace Shell_Application
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void btnNotepad_Click(object sender, EventArgs e)
        {
            try
            {
                Process.Start(@"C:\Windows\system32\notepad.exe");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        private void btnWindowsMediaPlayer_Click(object sender, EventArgs e)
        {
            try
            {
                Process.Start(@"C:\Program Files\Windows Media Player\wmplayer.exe");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        private void btnSoundRecorder_Click(object sender, EventArgs e)
        {
            try
            {
                Process.Start(@"C:\Windows\system32\SoundRecorder.exe");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        private void btnMSWord_Click(object sender, EventArgs e)
        {
            try
            {
                Process.Start(@"C:\Program Files\Microsoft Office\Office12\WINWORD.EXE");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        private void btnExcel_Click(object sender, EventArgs e)
        {
            try
            {
                Process.Start(@"C:\Program Files\Microsoft Office\Office12\EXCEL.EXE");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        private void btnOpenIrfanView_Click(object sender, EventArgs e)
        {
            try
            {
                Process.Start(@"C:\Program Files\IrfanView\i_view32.exe");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }


    }
}

Output Screen




On each Button Click it will open the associated Exe's

Output for Opening MS Excel



 

Excel Launch




Hope this will be useful

Page copy protected against web site content infringement by Copyscape

About the Author

Raj.Trivedi
Full Name: Raj Trivedi
Member Level:
Member Status: Member,MVP
Member Since: 6/16/2012 2:04:41 AM
Country: India
Regard's Raj.Trivedi "Sharing is Caring" Please mark as answer if your Query is resolved
http://www.dotnetfunda.com/profile/raj.trivedi.aspx
Raj Trivedi i.e. me started my career as Support Professional and then moved on the Software development eventually reached at these skills Software Development | Enthusiastic Blogger | Content Writer | Technical Writer | Problem Solver | Lecturer on Technology Subjects | Runnerup Award Winner on www.dotnetfunda.com and firm believer in Sharing as a way of Caring Yet this much achieved its still a long way to go and there is biggest dream lying to be one of the best entrepreneurs of India in Technology Department. The Dream has just started and i hope it follows. Highlights are mentioned in details in my profile at http://in.linkedin.com/pub/raj-trivedi/30/61/b30/

Login to vote for this post.

Comments or Responses

Login to post response

Comment using Facebook(Author doesn't get notification)