It seems that the command Shell() in VB.NET is becoming obsolete because of its out-datedness and other reasons, but i cant find a way i can still use a command line in my applications, Because I'm not that experienced with C#, I still don't know some of the basics, is there a way i can have the same usefullness of Shell() in C#, and please don't tell me to use Process.start() because that doesn't run command lines and the application that i have written in java sends information back to the console its running on, so it needs to be something similar to Shell(), if i can use Shell() in C# then please tell me how because i don't know how, thanks.

9 Years
Discussion Span
Last Post by Jx_Man

You can use ProcessStartInfo class to help you I am attaching an example it could help

This example I wrote to help me to generate key file for com and com+ applications

public void GenerateKeyFile(string path)
            string commandLine = " \"C:\\Program Files\\Microsoft Visual Studio 8\\SDK\\v2.0\\Bin\\sn.exe\" -k ";
            ProcessStartInfo PSI = new ProcessStartInfo("cmd.exe");
            PSI.RedirectStandardInput = true;
            PSI.RedirectStandardOutput = true;
            PSI.RedirectStandardError = true;
            PSI.UseShellExecute = false;
            Process p = Process.Start(PSI);
            System.IO.StreamWriter SW = p.StandardInput;
            System.IO.StreamReader SR = p.StandardOutput;
            SW.WriteLine(commandLine + path);

add reference (right click on project name) :
Microsoft Visual Basic.Net Runtime

add this on the top of code.

using System.Diagnostics;
using Microsoft.VisualBasic;

try this following code :

private void button1_Click(object sender, System.EventArgs e)
			Interaction.Shell("C:\\Documents and Settings\\Jerry\\My Documents\\Calck.exe", (AppWinStyle) 2, false, -1);

Thanks, it works great, do i need to add mscorlib.dll to the file of my application if i want it to run on other machines aswell?
and if i do, how do i get hold of it, where am i likely to find the dll?


actually i never tried to run it on other pc.
you can find the dll file in :
C:\Program Files\Microsoft Visual Studio .NET 2003\CompactFrameworkSDK\v1.0.5000\Windows CE -> mscorlib.dll

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.