[英]Command prompt should open one window close after 5 seconds and reopen
So what happens is it opens a command prompt with the command then it opens a second command prompt after 5 seconds and then closes second window after 5 more seconds and opens a second window again leaving 1st window still open.所以会发生什么是它打开一个带有命令的命令提示符,然后在 5 秒后打开第二个命令提示符,然后在 5 秒后关闭第二个窗口,然后再次打开第二个窗口,使第一个窗口仍然打开。 I need it to close the first window every 5 seconds and reopen it so theres only one window active not two.
我需要它每 5 秒关闭第一个窗口并重新打开它,这样只有一个窗口处于活动状态,而不是两个。 I can't have 2 windows open because im trying to open a proxy with the command and if the proxy is open on 1st command window itll stay the same and not connect on the second.
我无法打开 2 个窗口,因为我试图用命令打开一个代理,如果代理在第一个命令窗口上打开,它将保持不变并且不会在第二个窗口中连接。
Thread thread1;
private void Button1_Click(object sender, EventArgs e)
{
thread1 = new Thread(new ThreadStart(DoWork));
thread1.Start();
}
public void DoWork()
{
bool run = true;
while (run)
{
var lines = File.ReadAllLines(@"C:\Users\admin\source\repos\proxy\proxy\bin\Debug\proxies.txt");
var r = new Random();
var randomLineNumber = r.Next(0, lines.Length - 1);
var line2 = lines[randomLineNumber];
string line3 = line2.Replace(line2.Before(":") + ":", "");
line3 = line3.Replace(":" + line2.After(":"), "");
string strCmdText;
strCmdText = "/K proxy-login-automator -local_port 8082 -remote_host zproxy.lum-superproxy.io -remote_port 22225 -usr " + line3.After(":") + " -pwd proxypw & pause";
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.CreateNoWindow = false;
startInfo.UseShellExecute = true;
startInfo.FileName = "CMD.exe";
startInfo.WorkingDirectory = @"C:\Users\admin\source\repos\proxy\proxy\bin\Debug";
startInfo.WindowStyle = ProcessWindowStyle.Normal;
startInfo.Arguments = strCmdText;
using (Process exeProcess = Process.Start(startInfo))
{
Thread.Sleep(5000);
exeProcess.Kill();
}
}
Windows have program name Windows 有程序名称
Task Scheduler
任务计划程序
, you can put your program in there and set occur every 5 seconds , 你可以把你的程序放在那里并设置每 5 秒发生一次
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.