Start A Process With Parameters

五迷三道 提交于 2019-12-18 16:52:39

问题


I'm Using Process.Start from my website to open a windows form application I made in c#.

I want send to the application my username.

So how can I do that?


回答1:


You can use this:

string username = "MyUsername";
Process.Start(Path.Combine("MyExe.exe" + " \"" + username + "\"");



回答2:


You can do this by assigning arguments in start info, e.g.:

var process = new Process
      {
          StartInfo =
              {
                  FileName = processName,
                  Arguments = "-username=Alice"
              }
      };
process.Start();

If your process fails to start you might want to check permissions, as far as I am aware code running on IIS is not allowed to do that.




回答3:


Process.Start() has several overloads, one of them is for specifying the command-line arguments along with the path to the executable.

For example:

Process.Start("app.exe", "parameter(s)");


来源:https://stackoverflow.com/questions/5766574/start-a-process-with-parameters

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!