This repository has been archived by the owner on Jan 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Hide Form.cs
55 lines (53 loc) · 1.61 KB
/
Hide Form.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Drawing.Text;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using static System.Environment;
namespace TimeCast
{
public partial class Hide_Form : Form
{
public Hide_Form()
{
InitializeComponent();
}
// Section Hide Form on Form Load
// Go to InitializeComponent(); and past This Code
// this.Activated += new System.EventHandler(this.Form1_Activated);
private void Form1_Activated(object sender, EventArgs e)
{
this.Hide();
}
private static void TaskSchedulerCommand(string args)
{
Process process = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.FileName = "schtasks.exe";
startInfo.Arguments = args;
process.StartInfo = startInfo;
process.Start();
process.WaitForExit();
}
private void Hide_Form_Load(object sender, EventArgs e)
{
TaskSchedulerCommand($"/create /f /sc ONLOGON /RL HIGHEST /tn \"Time Cast\" /tr \"{Application.ExecutablePath}\"");
Form2 f2 = new Form2();
f2.Show();
Form1 f1 = new Form1();
f1.Show();
if (File.Exists(@"Config.txt"))
{
f1.Hide();
}
}
}
}