Start a process that requires user input (without user)

  • Thread starter Thread starter Z. V
  • Start date Start date
Z

Z. V

Guest
Hello,

In my application I have to run the following command and input the password Programmatically without user.

manage-bde -unlock K: -pw

If I run this in CMD, I get the following output:

BitLocker Drive Encryption: Configuration Tool version 10.0.10011
Copyright (C) 2013 Microsoft Corporation. All rights reserved.

Enter the password to unlock this volume:

At this point I should enter a password.

I used the following source code:


Process MyProcess = new Process();

ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = Environment.GetEnvironmentVariable("windir") + "/SysNative/manage-bde.exe";
startInfo.UseShellExecute = false;

startInfo.RedirectStandardOutput = true;
startInfo.RedirectStandardInput = true;

startInfo.RedirectStandardError = true;
startInfo.Arguments = "-unlock K: -pw";

MyProcess.StartInfo = startInfo;
MyProcess.Start();

StreamReader myStreamReader = MyProcess.StandardError;

Console.WriteLine("Error: " + myStreamReader.ReadLine());

myStreamReader = MyProcess.StandardOutput;
Console.WriteLine("Output: " + myStreamReader.ReadLine());

StreamWriter myStreamWriter = MyProcess.StandardInput;
myStreamWriter.WriteLine("12345678");
MyProcess.WaitForExit();


I got the following output:

Error:
Output: BitLocker Drive Encryption: Configuration Tool version 10.0.10011

It seems that the BitLocker exit without getting a password.

Can you please help ?

Thank you,

Zvika

Continue reading...
 
Back
Top