Answer the question
In order to leave comments, you need to log in
How to run a console application in C#?
There is a simple C# application, written in a notepad, it is a console one.
Accordingly, at startup, the console is launched and while the console is running, it looks so-so on slow PCs. Well, the question itself "How to launch a console application in C# hidden?", so that the console is minimized or not displayed to the user at all, the code for a greater understanding of the problem.
using System;
using System.Diagnostics;
using System.IO;
namespace Start1CEnterprise
{
class StartEnterprise
{
static void Main()
{
// сдесь задаем переменные версии нашей базы на сервере
string vers = "";
// режим запуска оставил просто так, но работает
string ForS = "";
// Сервер
string server = "";
// База
string bases = "";
// счетчик перебираемых атрибутов
int chek = 0;
// переберем все строки в файле и сохраним в переменные указанные выше
string[] param = File.ReadAllLines("param.txt");
foreach(string par in param)
{
switch(chek)
{
case 0: vers = par;break;
case 1: ForS = par;break;
case 2: server = par;break;
case 3: bases = par;break;
}
++chek;
}
string atributs = @"... /"+ForS+" "+server+@"\"+bases+@" ...";
string[] adress = new string[]
{
@"C:\Program Files (x86)\..\"+vers+@"\bin\...exe",
@"C:\Program Files (x86)\..\"+vers+@"\bin\...exe",
@"C:\Program Files\..\"+vers+@"\bin\...exe",
@"C:\Program Files\..\"+vers+@"\bin\...exe",
@"\\..\..\"+vers+@"\bin\...exe",
@"\\..\..\"+vers+@"\bin\...exe"
};
// проверим все адреса
foreach(string adres in adress)
{
// проверим есть ли файл по адресу
if(File.Exists(adres))
{
// запустим его
Process.Start(adres, atributs);
// не продолжаем перебирать и выйдем из цикла
break;
}
}
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question