Hi,
I am trying to get control of an opened command prompt.Is there any possible way to do that. So that i can directly pass arguments ie commands to command prompt using c# coding.
( I tried using process but only killing the process is working so that already opened command prompt can be closed using the c# code.)
shine_jose
-6
Light Poster
Recommended Answers
Jump to PostYou need to get a
MainwindowHandle
and activate it using P/invoke SetForegroundWindow().[DllImport("user32.dll")] static extern bool SetForegroundWindow(IntPtr hWnd); private void button1_Click(object sender, EventArgs e) { System.Diagnostics.Process proc = (from n in System.Diagnostics.Process.GetProcesses() where n.ProcessName == "cmd" select n).FirstOrDefault(); if (proc == null) { MessageBox.Show("No such a …
All 4 Replies
kvprajapati
1,826
Posting Genius
Team Colleague
shine_jose
-6
Light Poster
shine_jose
-6
Light Poster
shine_jose
-6
Light Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.