Answer the question
In order to leave comments, you need to log in
How to write a program that will run a friend's program?
Please help me find an example of a code that would launch an .exe file with a parameter:
Algorithm:
1. Reading the parameter from the file
2. Command line that needs to be executed many times (with each parameter from the file 1 time):
myfile.exe -1 -hhhh -h -PARAMETER AND FILE ( zzzzzz )
3. Timer 10 minutes, then shutdown of the running myfile.exe
4. If the file contains parameters with which the program was not launched, return to step 2, if all the parameters have already been launched, then Happy End and the program has finished working .
Contents of the parameter file:
aaaaaa
bbbbbb
ccccccc
dddddd
..........
zzzzzz
Help please?
Answer the question
In order to leave comments, you need to log in
The simplest solution, the contents of the start.bat file :
@echo off
for /f %%a in (1.txt) do (
echo Starting 'myfile.exe' with '%%a' argument...
start myfile.exe -1 -hhhh -h -%%a
echo started, waiting...
timeout 600
echo killing started application 'myfile.exe'...
taskkill /im myfile.exe
echo OK!
)
using System;
using System.Diagnostics;
namespace Example
{
class Program
{
static void Main(string[] args)
{
if(args[0] == "-first")
{
Console.WriteLine("First Run");
Process second_procces = new Process();
second_procces.StartInfo.UseShellExecute = true;
second_procces.StartInfo.FileName = @"Example.exe";
second_procces.StartInfo.Arguments = "-second";
second_procces.Start();
}
else if(args[0] == "-second")
{
Console.WriteLine("Second Run");
Console.ReadLine();
}
}
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question