I have a windows service that is calling an exe-file and i would need it to fake a user prompt somehow.
Currently I have this line:
System.Diagnostics.Process.Start("C:\\Windows\\System32\\tpmvscmgr.exe",
"create /name tpmvsc /pin default /adminkey random /generate");
This is fine but I do not want the pin to be "default". I want it to be a variable I have in the app. But the exe can only accept "default" or "prompt" as the pin arguments. I cant open an actual prompt from a service but I wonder if I can somehow use the prompt argument and send in the pin?
Any ideas?
ok been trying out the answers but dont fully understand them. Tried this:
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");
But it just opens a prompt but never writes anything in it.