Start a process that requires user input (without user) RRS feed

  • Question

  • 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;

    I got the following output:

    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,


    Wednesday, December 26, 2018 7:04 PM


All replies

  • Have you tried to redirect the Standard Input only and to remove the fragments that are related to other streams?

    • Edited by Viorel_MVP Wednesday, December 26, 2018 7:52 PM
    Wednesday, December 26, 2018 7:51 PM
  • It is quite possible that, for security purposes, the BitLocker tool will not allow its input to be redirected from a file.  If you type this, does it work?

        echo 12345678 | manage-bde -unlock K: -pw

    Tim Roberts | Driver MVP Emeritus | Providenza & Boekelheide, Inc.

    Thursday, December 27, 2018 1:47 AM
  • Hi Tim, Viorel, 

    I tried:

    echo 12345678 | manage-bde -unlock K: -pw

    and got:

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

    ERROR: An error occurred (code 0x80070006):
    The handle is invalid.

    I got the same response when I changed my code to:

    startInfo.RedirectStandardOutput = false;
    startInfo.RedirectStandardError = false;

    Thank you for your help,


    • Edited by Z. V Thursday, December 27, 2018 3:34 AM
    Thursday, December 27, 2018 3:32 AM
  • Hi Z. V,

    Thank you for posting here.

    For your question, I write a simple code.

    static void Main(string[] args)
                Process MyProcess = new Process();
                ProcessStartInfo startInfo = new ProcessStartInfo
                    FileName = Environment.GetEnvironmentVariable("windir") + "/SysNative/manage-bde.exe",
                    UseShellExecute = false,
                    Verb = "runsas",
                    Arguments = "-unlock D: -pw"
                MyProcess.StartInfo = startInfo;

    Test Result:

    Best regards,

    Jack J Jun.

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    Thursday, December 27, 2018 8:48 AM
  • Hi Jack,

    I tried your code. 

    Upon running, the user is asked to enter password (with Console.ReadKey ()).

    But I want the application to do it automatically. 

    Thank you,


    Thursday, December 27, 2018 8:15 PM
  • Maybe SendKeys?
    • Marked as answer by Z. V Friday, December 28, 2018 3:55 AM
    Thursday, December 27, 2018 8:24 PM
  • Hello RLWA32,

    I added:


    It works !

    Thank you very much,


    Friday, December 28, 2018 3:54 AM