|
-
February 19th, 2017, 08:40 AM
#1
Target (CMD) window & send input
Hello there,
I'm working on a small project of mine where I'd like to start CMD and execute few commands, one after another, with time delays. This is what I got so far:
Code:
Process proc = new Process();
proc.StartInfo.FileName = Server + "\\Server.bat";
proc.StartInfo.WorkingDirectory = Server;
proc.Start();
var stopwatch = Stopwatch.StartNew();
Thread.Sleep(90000);
stopwatch.Stop();
"Server.bat" opens the CMD and the stopwatch below is used as a timer (delay) for executing next command. Problem is, I have no idea how to make the CMD window active (it currently stays active, but just in case it gets minimized ..) and send commands to it, like "dir", "cd C:\blabla" with delays in between. I've googled my *** off and not a single example / solution worked for me (most of them call CMD.exe and pass 1 command to it, right after starting). I'm still pretty new to C# and would appreciate your help!
Ow and, another side project, is there an easy way to target specific running process (selected by name?) and change its priority (example: I have Firefox running and the code changes its priority to High or Realtime)?
Thank you!
-kind regards-
Gomo
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|