I am trying to run a console application in background
using powershell script
and in the main method of "program.cs" it requires user confirmation. Working of this console application is to update some configurations and settings before i install a main application.
ConsoleApp.exe -> below is sample code from my "Program.cs
public class Program
static void Main(string args)
public static void RunCommandLine()
Console.WriteLine("Do you wan to continue (Yes/No)?");
var response = Console.ReadKey();
Console.WriteLine("Working with - Yes");
Console.WriteLine("Working without -Yes");
What I have tried:
Following command is working fine when I am not running this "ConsoleApp.exe" in background
$wshell = New-Object -ComObject wscript.shell;
But it stop working when i run it in background using following command
Start-Process -NoNewWindow "c:\temp\ConsoleApp.exe"
possible reason is when running it in background, there is no interactive window to send keystrokes.
I have tried some other powershell commands as well like
echo Y | C:\Temp\ConsoleApp.exe
Write-Output Y | C:\Temp\ConsoleApp.exe
Is there any other way to achieve the same?