Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using System.IO;
- using System.ServiceProcess;
- namespace OneNeckInstaller
- {
- public partial class OneNeckInstallerFrm : Form
- {
- public OneNeckInstallerFrm()
- {
- InitializeComponent();
- }
- private void label1_Click(object sender, EventArgs e)
- {
- }
- private void btnNagiosAgent_Click(object sender, EventArgs e)
- {
- }
- private void OneNeckInstallerFrm_Load(object sender, EventArgs e)
- {
- // check if BGInfo is installed
- string winfold = System.Environment.GetEnvironmentVariable("windir");
- string bgInfoFile = winfold + @"\BGInfo.bmp";
- if (File.Exists(bgInfoFile)) {
- lblBGInfoStatus.Text = "installed";
- }
- else
- {
- lblBGInfoStatus.Text = "not installed";
- }
- // check if Nagios Agent is installed
- if (serviceRunning("NC_Net"))
- {
- lblNagiosAgentStatus.Text = "installed";
- }
- else
- {
- lblNagiosAgentStatus.Text = "not installed";
- }
- MessageBox.Show("got this far");
- // check if SNMP is installed
- if (serviceRunning("SNMP"))
- {
- lblSNMPServiceStatus.Text = "installed";
- } else {
- lblSNMPServiceStatus.Text = "not installed";
- }
- MessageBox.Show("didnt get this far");
- // check if SNARE is installed
- if (serviceRunning("SNARE"))
- {
- lblSnareStatus.Text = "installed";
- }
- else
- {
- lblSnareStatus.Text = "not installed";
- }
- }
- private bool serviceRunning(string serviceName)
- {
- bool result = false;
- ServiceController sc = new ServiceController(serviceName);
- switch (sc.Status)
- {
- case ServiceControllerStatus.Running:
- result = true;
- break;
- default:
- break;
- }
- return result;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement