Click here to Skip to main content
15,949,741 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello
i have a little asp.net program that in this program i could write and run commands of command prompt in my asp.net application An important part of this story is to run exe files with commands
it is my code but dont run exe file for example where i write mspaint it dont open
C#
try
       {
           Process p = new Process();
           p.StartInfo.CreateNoWindow = false;

           p.StartInfo.FileName = c_path.Value = Encoding.Default.GetString(Convert.FromBase64String(c_path.Value));
           c_text.Value = Encoding.Default.GetString(Convert.FromBase64String(c_text.Value));
           p.StartInfo.Arguments = c_text.Value;
           p.StartInfo.UseShellExecute = false;
           p.StartInfo.RedirectStandardInput = true;
           p.StartInfo.RedirectStandardOutput = true;
           p.StartInfo.RedirectStandardError = true;

           p.Start();

           string[] Uoc = new string[20];
           for (int i = 1; Uoc.Length > i; i++)
           {
               Uoc[i] = p.StandardOutput.ReadLine();
               Uoc[i] = Uoc[i].Replace("<", "<");
               Uoc[i] = Uoc[i].Replace(">", ">");
               Uoc[i] = Uoc[i].Replace("\r\n", "<br>");


           }

           string txt = "";
           foreach (var item in Uoc)
           {
               txt += item + "<br />";
           }
           cmd_response.InnerHtml = "<hr width=\"100%\" noshade/><pre>" + txt + "";
           cmd_response.Visible = true;
           more.Visible = true;

       }
       catch (Exception error)
       {
           xseuB(error.Message);
       }
Posted
Updated 16-Dec-13 19:12pm
v2

1 solution

Yes it does.
But...C# code executes on the server, not the client. So any application you run via Process.Start runs on the Server, not the Client - so two things happen:

1) Your user cannot see it.
2) Your web admin starts to get annoyed with you...

You cannot execute an application directly on the client except under specific conditions which do not occur in the vast majority of circumstances for security reasons. Think about it: your client could be on an iPad for example - Windows apps will not run...
 
Share this answer
 
Comments
[no name] 17-Dec-13 2:16am    
tanx but ...
It is important for me to just run the exe file
please check my code
and tell me why it dont run exe file Even the local
OriginalGriff 17-Dec-13 3:14am    
If you actually want to run it on the server, you will probably have to talk to your hosting service or web admin and get your site running as an appropriate user who has permission to access the folder and execute the software - if it is actually installed, which if not guaranteed. But don't expect the user to see it, because he won't!
[no name] 18-Dec-13 1:37am    
dear orginalGriff
i am a green hat hachker
how can call to server and :-P
tanx
OriginalGriff 18-Dec-13 3:55am    
We do not support, condone or assist in any way with any form of hacking.
Please take your enquiry and yourself to a site where that kind of behaviour is encouraged.
Don't forget to disable your firewall and turn off your virus checker first!

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900