Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Start A Process With Parameters

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?

like image 459
Or Betzalel Avatar asked Apr 23 '11 20:04

Or Betzalel


People also ask

How do I start a process in PowerShell?

If you specify a non-executable file, Start-Process starts the program that's associated with the file, similar to the Invoke-Item cmdlet. You can use the parameters of Start-Process to specify options, such as loading a user profile, starting the process in a new window, or using alternate credentials.

How are arguments passed in the start-process?

Using Arguments with Start-Process Probably your first thought is to add the arguments between the quotes in the filepath, but as you might have noticed, that won't work. To pass arguments to the process that you want to start, you will need to use the -arguments parameter.

How do I start a process in C#?

C# Process run program Diagnostics; using var process = new Process(); process. StartInfo. FileName = "notepad.exe"; process. Start();

What is ArgumentList in PowerShell?

-ArgumentList Specifies parameters or parameter values to use when this cmdlet starts the process. Arguments can be accepted as a single string with the arguments separated by spaces, or as an array of strings separated by commas.


1 Answers

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.

like image 105
oleksii Avatar answered Sep 29 '22 21:09

oleksii