Solved

Executing Commands

Posted on 2004-09-26
2
198 Views
Last Modified: 2010-05-05
Good evening, all,

From a C# "Windows Application", how do I execute system command on "button1_click"?  For example, the "net send" command.  If I wanted to send a message across the LAN to SysAdmin from Console I'd just type "net send SysAdmin message".  I want to translate that to C#...  I hope I make sense LOL.  Thanks in advance!

Regards,
Tony
0
Comment
Question by:fattumsdad
2 Comments
 
LVL 10

Accepted Solution

by:
eternal_21 earned 500 total points
ID: 12156772
Use this:

  System.Diagnostics.Process process = new System.Diagnostics.Process();
  process.StartInfo.FileName = "cmd";
  process.StartInfo.UseShellExecute = false;
  process.StartInfo.Arguments = "/c net send * Hello World!";
  process.Start();

Obviously, replace the "net send * Hello World!" with whatever command line executable you would be running.
0
 
LVL 1

Author Comment

by:fattumsdad
ID: 12156785
Eternal,

As always, thanks for your help!!!
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now