Hello
It is a windows_task_scheduler.
1) This is a console app project. MainForm(Form) was added Here. (MainForm(Form) was added to the console project.)
2) after registering as a windows task scheduler,
3) the console_window should not appear when operating as a windows_task_scheduler.<====== When Not Environment.UserInteractive
4) If you double-click and run an exe other than the windows_task_scheduler, MainForm(Form) should appear. <====When Environment.UserInteractive
Please Help me...
It is a windows_task_scheduler.
1) This is a console app project. MainForm(Form) was added Here. (MainForm(Form) was added to the console project.)
2) after registering as a windows task scheduler,
3) the console_window should not appear when operating as a windows_task_scheduler.<====== When Not Environment.UserInteractive
4) If you double-click and run an exe other than the windows_task_scheduler, MainForm(Form) should appear. <====When Environment.UserInteractive
C#:
namespace Windows_Task_Scheduler
{
class Program
{
static void Main(string[] args)
{
string mtxName = "Windows_Task_Scheduler";
// Mutex Create
bool createdNew;
Mutex mutex = new Mutex(true, mtxName, out createdNew);
if (createdNew)
{
if (Environment.UserInteractive)
{ // UserInteractive Windows User interface
// Show - Windows Forom
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainForm());
}
else
{ // IIS or Windows_Task_Scheduler
<==== Hide ===> Console Windows
<==== Hide ===> MainForm
[B][I]<============ <==== Hide ===> Console Windows & MainForm How to do....[/I][/B]
}
}
else
{
Console.WriteLine("Error: Program is already running");
return;
}
// Mutex Release
mutex.ReleaseMutex();
}
}
}
Please Help me...
Last edited: