【问题标题】:After running cmd command, need to enter account and password, then close it using C# [duplicate]运行cmd命令后,需要输入账号和密码,然后用C#关闭[重复]
【发布时间】:2017-04-11 03:20:03
【问题描述】:

我需要在命令行中输入帐号和密码。我怎样才能做到这一点?我正在使用以下代码。

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

以下是cmd 进程产生的预期提示:

【问题讨论】:

  • 我无法写入帐号和密码以继续执行命令
  • 我认为你的问题基本上得到了回答here
  • 创建一个附加到 process.StandardInputuse streamObj.WriteLine() 的 StreamWriter 流可能吗?你的问题不清楚。此外,batch-file 标签似乎与此问题无关。

标签: c#


【解决方案1】:

您必须有一个“用户”数据库,其中包含用户名和密码。 在命令行中询问用户需要的输入,并与您的密码数据库一起检查。 DB可以是您的情况允许的。例如简单的 List 或类似的东西。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-01-08
    • 2010-12-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-19
    • 2015-03-14
    • 2021-08-04
    相关资源
    最近更新 更多