0

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.

Johannes
  • 33
  • 1
  • 8

1 Answers1

0

You could use the "/pin prompt" argument and set the StandardInput of the process to feed the process with the desired pin. Check the MSDN link below

https://msdn.microsoft.com/es-es/library/system.diagnostics.process.standardinput(v=vs.110).aspx

BTW, probably there is a similar/duplicated question.

Cleptus
  • 3,446
  • 4
  • 28
  • 34