santhosh
santhosh

Reputation: 11

how to open command prompt using asp.net

Please try to help me.. How to open and write commands in Command Prompt using asp.net3.5,C#.net...

if i click a Button in my UI it should open the commaond Prompt and i want excute few commands there...

Thank you..

Upvotes: 1

Views: 6790

Answers (3)

Justin
Justin

Reputation: 86729

It sounds like you want to open the command prompt from a browsers on the client PC.

To do this you either need to:

  • Use an ActiveX control, which will require that the user approve the installation of the ActiveX control.
  • Use the WScript.Shell object which is very unlikely to be available (for security reasons) unless your site is in a "very trusted" zone.

I.e. you can't expect a normal user to allow this to happen - this is only really going to be useful on your own PC.

If this is OK then you can find an example of running an application from JavaScript using the WScript.Shell object here (this is the easiest of the two options).

Upvotes: 1

Sergey K
Sergey K

Reputation: 4114

Try to use this code you need to add the namespace

using System.Diagnostics;

 var processStartInfo = new ProcessStartInfo
                                   {
                                       Arguments = "ping google.com",
                                       FileName = "cmd"
                                   };

        Process process = Process.Start(processStartInfo);

Upvotes: 2

Shekhar_Pro
Shekhar_Pro

Reputation: 18430

You said

if i click a Button in my UI

so do you mean on the client side from browser.. sorry that's not possible from any JavaScript Code. You can't start a process on clients system with any code running in Browser. Something should be installed as a Desktop app to do that.

Upvotes: 0

Related Questions