0

I need to enter account and password in command line. How Can I achieve this? I'm using the following code.

    Process process = new Process();
    ProcessStartInfo startInfo = new ProcessStartInfo();
    startInfo.FileName = @"cmd.exe";
    startInfo.Arguments = @"/k" + Commmand;
    process.StartInfo = startInfo;
    process.Start();

Below are the expected prompts resulting from the cmd process:

enter image description here

enter image description here

rojo
  • 24,000
  • 5
  • 55
  • 101
Rosa
  • 1
  • 3
  • I cannot write the account and password to continue the command – Rosa Apr 11 '17 at 03:22
  • I think what you're asking is essentially answered [here](http://stackoverflow.com/questions/10530303/execute-a-program-which-accept-command-line-parameters). – Dan Apr 11 '17 at 03:23
  • Create a StreamWriter stream attached to `process.StandardInput` and [use `streamObj.WriteLine()`](https://msdn.microsoft.com/en-us/library/system.diagnostics.process.standardinput(v=vs.110).aspx) maybe? Your question is unclear. Also, the `batch-file` tag doesn't seem relevant to this question. – rojo Apr 11 '17 at 03:25
  • Or maybe here http://stackoverflow.com/questions/3308500/run-interactive-command-line-exe-using-c-sharp – Etienne Apr 11 '17 at 03:25

1 Answers1

0

You must have a DB of "users", thant contains usernames and passwords. In command line ask from a user needed input and check it with you DB of passwords. DB can be anithing that is allowable in your case. For example simple List or smth like that.

David Oganov
  • 976
  • 1
  • 11
  • 23