I have a .exe file which when called from the Windows Command prompt, first connects to a server and then requests for user input as a confirmation. Something like below:
C:\SomePath\AnotherFolder>TheApplication.exe download
Logging in to Vault server myserver.app.cosmos...
Logged in to the Vault server
Downloading will overwrite existing files.
Download scripts for context 'COSMOS' to folder:
C:\Work\MyFolder\TEST?
(y/n): n <--- n was my input
Press any key to exit... <--- here i pressed y
I want to automate this process.
I tried the below line from the Windows command prompt:
echo n|TheApplication.exe download
I even tried :
(echo n && echo y)|TheApplication.exe download <-- the y for the last user input request to close the app.
But in both cases its throwing the below error:
Unhandled Exception: System.InvalidOperationException: Cannot read keys when either application does not have a console or when console input has been redirected from a file. Try Console.Read.
at System.Console.ReadKey(Boolean intercept)
at System.Console.ReadKey()
at TheApplication.Program.Main(String[] args)
**disclaimer: TheApplication.exe is a third party executable. I cannot change anything inside it.
PS: If needed I can run this from a powershell console if its not possible from windows command prompt or I can also include the whole thing inside a batch script.
But any how I need to automate this.