Click here to Skip to main content
15,867,568 members
Articles / Programming Languages / Shell
Alternative
Tip/Trick

Running a(ny) shell command using C#

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
12 Feb 2011CPOL 8.5K  
Something I only found out about recently:There's a better alternative than using "cmd start...".One should use the following method:[System.Runtime.InteropServices.DllImport("shell32. dll")]private static extern long ShellExecute(Int32 hWnd, string lpOperation,string lpFile, string...
Something I only found out about recently:
There's a better alternative than using "cmd start...".

One should use the following method:
C#
[System.Runtime.InteropServices.DllImport("shell32. dll")]
private static extern long ShellExecute(Int32 hWnd, string lpOperation,
string lpFile, string lpParameters, string lpDirectory, long nShowCmd);


This method is used according to what's written
here[^].

If it helps, there's a guy who gave a good example of the usage (although it's written in C) in here[^].

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
-- There are no messages in this forum --