C#调用带有参数的exe进行提示
我有一个windows服务正在调用exe文件,我需要它以某种方式伪造用户提示 目前我有这一行:C#调用带有参数的exe进行提示,c#,command,C#,Command,我有一个windows服务正在调用exe文件,我需要它以某种方式伪造用户提示 目前我有这一行: System.Diagnostics.Process.Start("C:\\Windows\\System32\\tpmvscmgr.exe", "create /name tpmvsc /pin default /adminkey random /generate"); 这很好,但我不希望pin为“默认”。我希望它是我在应用程序中的一个变量。 但是exe只能接受“default
System.Diagnostics.Process.Start("C:\\Windows\\System32\\tpmvscmgr.exe",
"create /name tpmvsc /pin default /adminkey random /generate");
这很好,但我不希望pin为“默认”。我希望它是我在应用程序中的一个变量。
但是exe只能接受“default”或“prompt”作为pin参数。
我无法从服务中打开实际的提示,但我想知道是否可以使用提示参数并发送pin
有什么想法吗
好的,我一直在尝试答案,但没有完全理解。
我试过这个:
Process myProcess = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = "C:\\Windows\\System32\\tpmvscmgr.exe";
startInfo.Arguments = "create /name tpmvsc /pin prompt /adminkey random /generate";
startInfo.RedirectStandardInput = true;
startInfo.UseShellExecute = false;
myProcess.StartInfo = startInfo;
myProcess.Start();
System.IO.StreamWriter myStreamWriter = myProcess.StandardInput;
while (true)
myStreamWriter.WriteLine("123456789");
但它只是打开一个提示符,但从不在其中写入任何内容。您可以使用“/pin-prompt”参数并设置进程的StandardInput,以向进程提供所需的pin。检查下面的MSDN链接
顺便说一句,可能有一个类似的/重复的问题。为什么?Windows服务应在无人参与的情况下运行,谁将单击“确定/取消”?我知道OP希望在无人参与的情况下运行它,但提供该值的唯一方法是使用默认值或提示中的值。我想OP想问的是:如何从无人参与的进程向提示符提供一个值?是的,帕特里克,听起来不错。不知道,我在上面快速搜索了一下。是java吗?我该怎么用?你是说?看看复制品。