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?
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.
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.
C# Process run program Diagnostics; using var process = new Process(); process. StartInfo. FileName = "notepad.exe"; process. Start();
-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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With