Skip to content

Commit 7fc97ef

Browse files
Updated Installer
1 parent 1984311 commit 7fc97ef

3 files changed

Lines changed: 63 additions & 19 deletions

File tree

Installer/Install.cs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,18 @@ public Option(string name, int id, bool check)
2121
public static class Install
2222
{
2323
static bool done;
24-
static int percentage;
25-
public static string appdataDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "EZCode");
26-
public static string tempDirectory = Path.Combine(Path.GetTempPath(), "EZCode");
24+
public static string appdataDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "EZCode");
25+
public static string tempDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), "Temp", "EZCode");
2726
public static string filepath = "C:\\Program Files\\EZCode\\";
27+
public static string githubRepoUrl = "https://github.com/JBrosDevelopment/EZCode";
2828
static string _MainText;
29+
static int percentage;
2930
static string MainText
3031
{
3132
get => _MainText;
3233
set
3334
{
3435
_MainText = value;
35-
//Console.WriteLine(_MainText);
3636
}
3737
}
3838
public static void DownloadMain()
@@ -41,9 +41,8 @@ public static void DownloadMain()
4141
Option[] options = Options();
4242
try
4343
{
44-
string githubRepoUrl = "https://github.com/JBrosDevelopment/EZCode";
45-
string type = "Official";
46-
string realTag = "2.0.0";
44+
string type = "";
45+
string realTag = "2.0.2";
4746
string releaseTag = type != "" ? $"v{realTag}_{type.ToLower()}" : $"v{realTag}";
4847
string releaseTitle = type != "" ? $"v{realTag}_{type}" : $"v{realTag}";
4948

@@ -116,8 +115,8 @@ void ezcodeplayer() // Install EZCode Main
116115
}
117116
Directory.Delete(tempDirectory, true);
118117

119-
Program.CreateShortcut("EZCode", Path.Combine(decompressDirectory, "EZCodePlayer.exe"));
120-
118+
Program.CreateShortcut("EZCode Player", Path.Combine(decompressDirectory, "EZCodePlayer.exe"));
119+
Program.CreateStartMenuShortcut("EZCode", "EZCode Player", Path.Combine(decompressDirectory, "EZCodePlayer.exe"));
121120
Program.SetUpFile(Path.Combine(decompressDirectory, "EZCodePlayer.exe"), Path.Combine(appdataDir, "EZCode", "EZCode_Logo.ico"));
122121
}
123122

@@ -146,6 +145,7 @@ void slnbuilder() // Install Sln Builder
146145
Directory.Delete(tempDirectory, true);
147146

148147
Program.CreateShortcut("SLN Builder", Path.Combine(decompressDirectory, "EZ_SLN_Builder.exe"));
148+
Program.CreateStartMenuShortcut("EZCode", "SLN Builder", Path.Combine(decompressDirectory, "EZ_SLN_Builder.exe"));
149149
}
150150

151151
void ez_ide() // Install IDE
@@ -172,7 +172,8 @@ void ez_ide() // Install IDE
172172
}
173173
Directory.Delete(tempDirectory, true);
174174

175-
Program.CreateShortcut("EZCode IDE", Path.Combine(decompressDirectory, "EZ_IDE.exe"));
175+
Program.CreateShortcut("EZ IDE", Path.Combine(decompressDirectory, "EZ_IDE.exe"));
176+
Program.CreateStartMenuShortcut("EZCode", "EZ IDE", Path.Combine(decompressDirectory, "EZ_IDE.exe"));
176177
}
177178
}
178179
catch (Exception ex)

Installer/Program.cs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,17 @@ static void Main(string[] args)
1919

2020
ConsoleKey key;
2121

22+
string txt1 = "Welcome to EZCode Installer! What would you like to do today?";
23+
string txt2 = "\nUse the arrow keys to select an option, press enter to submit.";
24+
Console.ForegroundColor = ConsoleColor.Blue;
25+
Console.WriteLine(txt1);
26+
Console.ResetColor();
27+
Console.WriteLine(txt2);
28+
2229
do
2330
{
2431
Console.Clear();
2532

26-
string txt1 = "Welcome to EZCode Installer! What would you like to do today?";
27-
string txt2 = "\nUse the arrow keys to select an option, press enter to submit.";
2833
Console.ForegroundColor = ConsoleColor.Blue;
2934
Console.WriteLine(txt1);
3035
Console.ResetColor();
@@ -109,6 +114,16 @@ public static void CreateShortcut(string name, string path)
109114
shortcut.TargetPath = path;
110115
shortcut.Save();
111116
}
117+
public static void CreateStartMenuShortcut(string folderName, string name, string path)
118+
{
119+
WshShell shell = new WshShell();
120+
string startMenuFolder = Environment.GetFolderPath(Environment.SpecialFolder.StartMenu);
121+
string shortcutAddress = Path.Combine(startMenuFolder, "Programs", folderName, $"{name}.lnk");
122+
Directory.CreateDirectory(Path.GetDirectoryName(shortcutAddress));
123+
IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(shortcutAddress);
124+
shortcut.TargetPath = path;
125+
shortcut.Save();
126+
}
112127

113128
[DllImport("Shell32.dll", CharSet = CharSet.Auto, SetLastError = true)]
114129
public static extern void SHChangeNotify(uint wEventId, uint uFlags, IntPtr dwItem1, IntPtr dwItem2);

Installer/Uninstall.cs

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,22 +60,50 @@ static void Remove()
6060
Install.CreateDirs();
6161
Console.Clear();
6262
Console.Write("Uninstalling...");
63+
64+
// Remove program files and directories
6365
Directory.Delete(Install.appdataDir, true);
6466
Directory.Delete(Install.filepath, true);
65-
object shDesktop = (object)"Desktop";
66-
WshShell shell = new WshShell();
67-
string shortcutAddress1 = (string)shell.SpecialFolders.Item(ref shDesktop) + $"\\EZCode.lnk";
68-
string shortcutAddress2 = (string)shell.SpecialFolders.Item(ref shDesktop) + $"\\SLN Builder.lnk";
69-
if (File.Exists(shortcutAddress1)) File.Delete(shortcutAddress1);
70-
if (File.Exists(shortcutAddress2)) File.Delete(shortcutAddress2);
67+
68+
// Remove desktop shortcuts
69+
RemoveDesktopShortcut("EZCode Player.lnk");
70+
RemoveDesktopShortcut("SLN Builder.lnk");
71+
RemoveDesktopShortcut("EZ IDE.lnk");
72+
73+
// Remove Start Menu shortcuts
74+
RemoveStartMenuShortcut();
75+
7176
Console.Write(" Done!");
7277
}
7378
catch (Exception ex)
7479
{
7580
Console.ForegroundColor = ConsoleColor.DarkRed;
76-
Console.WriteLine($"\nError during installation: {ex.Message}");
81+
Console.WriteLine($"\nError during uninstallation: {ex.Message}");
7782
Console.ResetColor();
7883
}
7984
}
85+
86+
static void RemoveDesktopShortcut(string shortcutName)
87+
{
88+
object shDesktop = (object)"Desktop";
89+
WshShell shell = new WshShell();
90+
string shortcutAddress = Path.Combine((string)shell.SpecialFolders.Item(ref shDesktop), shortcutName);
91+
92+
if (File.Exists(shortcutAddress))
93+
{
94+
File.Delete(shortcutAddress);
95+
}
96+
}
97+
98+
static void RemoveStartMenuShortcut()
99+
{
100+
string startMenuFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.StartMenu), "Programs", "EZCode");
101+
102+
if (Directory.Exists(startMenuFolder))
103+
{
104+
Directory.Delete(startMenuFolder, true);
105+
}
106+
}
107+
80108
}
81109
}

0 commit comments

Comments
 (0)