Friday, April 6, 2007

Shell Command Using C#

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace ProjTesting
{
///


/// Summary description for Form1.
///

public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Button btTriIE;
///
/// Required designer variable.
///

private System.ComponentModel.Container components = null;

public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();

//
// TODO: Add any constructor code after InitializeComponent call
//
}

///
/// Clean up any resources being used.
///

protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///

private void InitializeComponent()
{
this.btTriIE = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// btTriIE
//
this.btTriIE.Location = new System.Drawing.Point(32, 32);
this.btTriIE.Name = "btTriIE";
this.btTriIE.TabIndex = 0;
this.btTriIE.Text = "Trigger IE";
this.btTriIE.Click += new System.EventHandler(this.btTriIE_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 273);
this.Controls.Add(this.btTriIE);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);

}
#endregion

///
/// The main entry point for the application.
///

[STAThread]
static void Main()
{
Application.Run(new Form1());
}

private void btTriIE_Click(object sender, System.EventArgs e)
{


System.Diagnostics.Process Proc = new System.Diagnostics.Process();

/*System.Diagnostics namespace provides classes that allow you to interact with system processes, event logs, and performance counters.*/

/*Process Class which Provides access to local and remote processes and enables you to start and stop local system processes.*/


Proc.StartInfo.FileName = "IEXPLORE.EXE";

/*Process.StartInfo Class class which Specifies a set of values used when starting a process, StartInfo Gets or sets the properties to pass to the Start method of the Process.FileName is the Public Properties of ProcessStartInfo which Gets or sets the application or document to start.*/



Proc.StartInfo.WorkingDirectory = @"%Program Files%\Internet Explorer\";


/* WorkingDirectory this also an Public Properties of ProcessStartInfo which Gets or sets the initial directory for the process to be started.*/


Proc.StartInfo.Arguments= "http://www.xploredotnet.blogspot.com/";


/* Arguments is Public Properties Of StartInfoClass which Gets or sets the set of command line
arguments to use when starting the application.*/


Proc.Start();

/* Start Is Public Methods Of Process Members Overloaded. Starts a process resource and associates it with a Process component.*/


}
}
}




No comments:

Creative Commons License
Disclaimers:We have tried hard to provide accurate information, as a user, you agree that you bear sole responsibility for your own decisions to use any programs, documents, source code, tips, articles or any other information provided on this Blog.