0

I have a C# program. Let's say I have a string like this:

string test = "dir";

Then I run the program via a cmd: (it's a command line .NET program btw)

C:\Users\testuser\source\repos\test\test\bin\Debug> testprogram.exe

I want the program to launch the "test" string, however it needs to be from the same CMD instance. For example, it would look something like this in a Batch file:

@echo off
dir

If I executed this batch script, it would do it on the same CMD instance. I know you can do Process.Start();, however that launches a completely new instance of CMD.

senge1337
  • 19
  • 4
  • You can launch the process, redirect/capture its output, and send(write) it to the console that started C#.. What's the use case? – Caius Jard Jan 17 '22 at 16:40
  • @CaiusJard I gave up on this project, but it wouldn't fit my use case. It would have to be truly on the same cmd instance. Every question I asked on StackOverflow so far got an answer of impossible. ... – senge1337 Feb 01 '22 at 11:21
  • It might help to back up a level and tell us what the overall goal is; nothing's impossible, but sometimes if we track into a corner the better solve is to backtrack and go a different way. Why make a C# exe that runs from a batch script? Why not just write all the functionality into the C#? Batch file is very primitive compared – Caius Jard Feb 01 '22 at 12:26

0 Answers0