0
I made an application in C#, in addition to performing the basic functions, I want it to be possible to run with scripts in batches, but the problem is that I run Console.WriteLine
and he doesn’t write anything on the CMD window.
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Programs
{
static class Program
{
static Mutex mutex = new Mutex(true, "TS4");
///
/// The main entry point for the application.
///
[STAThread]
static void Main(string[] args)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
if (mutex.WaitOne(TimeSpan.Zero, true))
{
if (args.Length > 0)
{
Application.Run(new Form_Install());
}
else
{
Trace.WriteLine("Missing Var packed_filename");
Trace.WriteLine("Missing Var packed_game");
Trace.WriteLine("Missing Var packed_type");
MessageBox.Show("Parâmetros não encontrados.");
}
mutex.ReleaseMutex();
Trace.WriteLine("Mutex foi lançado!");
}
else
{
MessageBox.Show("Erro ao processar solicitação! O aplicativo já está em execução, termine a outra instalação e tente novamente!" , "O Thread atual já está em uso!" , MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
I’ve also heard of Trace.WriteLine
, but it didn’t work either!
It will not write on CMD. This is a Winforms application
– Jéf Bueno
Ah ta thought that even being from GUI it generates output! But so has to hide the console window?
– FRNathan13
Look even though I have switched to Console Application it does not write anything in cmd
– FRNathan13
It even generates output, but it’s not in CMD. Switching to the App Console probably won’t help. I think the ideal is to create a Console App.
– Jéf Bueno
Are you using Console.Write after you switched to console? @Nathan1302
– PauloHDSousa
Yes it worked I switched the
Trace
forConsole
and it worked. But how do I hide the CMD window from my app?– FRNathan13
Do you want to run a cmd command and keep your console application window hidden? If so, I’ve built an example.
– gato