简体   繁体   中英

How to run program through command line from .aspx page

I'm trying to run a program, say "robocopy.exe", through an aspx page using the System.Diagnostics.Process object.

My code looks like this:

Process si = new Process();
si.StartInfo.UserName = "testuser";
si.StartInfo.Password = password;
si.StartInfo.FileName = "cmd.exe";
si.StartInfo.UseShellExecute = false;       

si.StartInfo.Arguments = "c/ robocopy.exe";

si.Start();
string output = si.StandardOutput.ReadToEnd();
si.Close();

Label1.Text = output;

The problem is that the cmd.exe process is started correctly, but nothing happens. The argument of roboxopy.exe is presumably not passed to the cmd process to run! Any ideas as to what Icould be doing wrong?

Sounds like a permission issue. Usually the default asp_net account that any IIS processes run under will not have execute permissions on the server. The reason that this is the case is because it is a huge security hole. I would highly recommend that you think about what you are trying to accomplish and see if there is another way to do it that does not involve running a separate executable.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM