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.

Recommended Answers

All 4 Replies

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.