Skip to content

Commit

Permalink
feat: health check app
Browse files Browse the repository at this point in the history
  • Loading branch information
Xlin123 committed Oct 1, 2024
1 parent 57d0d1f commit 95cc8c6
Show file tree
Hide file tree
Showing 10 changed files with 1,321 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tools/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ bin
obj
*.user
launchSettings.json
windows-installer/NoPortsInstaller/Resources/*
windows-installer/NoPortsInstaller/Resources/*
windows-installer/NoPortsHealthCheck/publish
6 changes: 6 additions & 0 deletions tools/windows-installer/NoPortsHealthCheck/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
</startup>
</configuration>
239 changes: 239 additions & 0 deletions tools/windows-installer/NoPortsHealthCheck/Form1.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 58 additions & 0 deletions tools/windows-installer/NoPortsHealthCheck/Form1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
using Microsoft.Win32;
using System;
using System.Windows.Forms;

namespace NoPortsHealthCheck
{
public partial class Form1 : Form
{
static readonly string userHome = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
static readonly string localAppData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
readonly bool isUserAdmin = Program.IsUserAdmin();
readonly bool canWriteUserHome = Program.CanWriteToDirectory(userHome);
readonly bool canWriteLocalAppData = Program.CanWriteToDirectory(localAppData);
readonly bool canWriteNetworkService = Program.CanWriteToDirectory(Environment.ExpandEnvironmentVariables("%systemroot%")
+ @"\ServiceProfiles\LocalService\");
readonly bool canWriteRegistry = Program.CanWriteToRegistry(Registry.LocalMachine, "SOFTWARE\\TestKey");
readonly bool canModifyPath = Program.CanModifyEnvironmentVariable();
readonly bool canCreateServices = Program.CanCreateServices();
public Form1()
{
InitializeComponent();
this.Text = "NoPorts Health Check";
checkBox1.Checked = isUserAdmin;
if (isUserAdmin)
{
Program.Log("User is Admin");
}
else
{
Program.Log("User is not Admin, try running as admin.");
}
checkBox2.Checked = canWriteUserHome;
checkBox3.Checked = canWriteLocalAppData;
checkBox4.Checked = canWriteNetworkService;
checkBox5.Checked = canWriteRegistry;
checkBox6.Checked = canModifyPath;
checkBox7.Checked = canCreateServices;
if (isUserAdmin && canWriteUserHome && canWriteLocalAppData && canWriteNetworkService && canWriteRegistry && canModifyPath && canCreateServices)
{
Program.ShowSuccessLogs();
}
if (!isUserAdmin)
{
Program.ShowErrorLogs();
}
}

private void label8_Click(object sender, EventArgs e)
{

}

private void checkBox7_CheckedChanged(object sender, EventArgs e)
{

}
}
}
Loading

0 comments on commit 95cc8c6

Please sign in to comment.