How can I run any win.exe from the asp.net page?
How can I run any win.exe from the asp.net page?
this causes me an error: The system cannot find the file specified
System.Diagnostics.Process process1 = new System.Diagnostics.Process();
process1.StartInfo.WorkingDirectory = Request.MapPath(@"C:\");
process1.StartInfo.FileName = Request.MapPath("WindowsApplication1.exe");
process1.Start();
a source to share
Remember, the code you posted there is running on your web server. It does not work and cannot work on the user's machine. This would be a major security issue — significant enough to render the network virtually useless.
If that's your intention, you just need to make sure that your asp.net account - which usually runs with very limited permissions for security reasons - has the proper permissions, access, and trust to run the requested program. Otherwise, you will need to do something else.
a source to share
You don't need Request.MapPath () for what you are doing as you are already using the local path. Request.MapPath () is used to translate the application URL (for example, "~ / test.htm") to a local path (for example, "c: \ inetpub \ wwwroot \ myapp \ test.htm").
Does the application exist at c: \ WindowsApplication1.exe on the server ?
a source to share
Try this
System.Diagnostics.Process process1 = new System.Diagnostics.Process();
process1.StartInfo.FileName = "C:\WindowsApplication1.exe";
process1.Start();
So the application is first loaded and then launched. I don't think it will work from the server.
If you want to run it from a server, the better you write your application in flash or silverlight / moonlight.
a source to share
What are you trying to do?
Your goal is to do this on the clients' computer (you cannot do this).
If it's just some .exe file that you want to execute on your server when a user views this page (I won't even start with why this is a bad idea), then you are doing some silly thing.
No need for Request.MapPath
around your filenames.
You also need to make sure your web server user identity account has permission to access and run the file
a source to share
Request.MapPath takes a relative url and returns the local filename (on the server) eg. Request.MapPath("test.aspx")
can return C:\inetpub\wwwroot\MyApp\Test.aspx
.
So basically your "web page" will look for an application on the server in the same directory as the web page called WindowsApplcation1.exe.
Finally - if you expect this Windows application to run on the client, this won't work as it will run the application on the server. Auto-run files on the client will not be allowed as this would be a security risk.
a source to share
I am doing this:
var client = new Client(Int32.Parse(Session["uid"].ToString()));
var genReceipt = new Process();
genReceipt.StartInfo.FileName = "Chitanta_unit.exe";
genReceipt.StartInfo.WorkingDirectory = @"C:\chitanta_unit\";
genReceipt.StartInfo.Arguments = client.ClientID.ToString();
genReceipt.Start();
genReceipt.WaitForExit();
if (genReceipt.ExitCode == 0)
{
Response.Redirect("~/subscriber/ch/" + client.GetChitantaFilename());
}
genReceipt.Close();
The client class contains operations with clients. The path "C: \ chitanta_unit \" on the server. The server is all mine =) I started it with the clientID argument. And Chitanta_unit.exe is ConsoleApplication
Works well