Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.47 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using System.IO;
  10. using System.ServiceProcess;
  11.  
  12.  
  13.  
  14. namespace OneNeckInstaller
  15. {
  16.     public partial class OneNeckInstallerFrm : Form
  17.     {
  18.         public OneNeckInstallerFrm()
  19.         {
  20.             InitializeComponent();
  21.         }
  22.  
  23.         private void label1_Click(object sender, EventArgs e)
  24.         {
  25.  
  26.         }
  27.  
  28.         private void btnNagiosAgent_Click(object sender, EventArgs e)
  29.         {
  30.  
  31.         }
  32.  
  33.         private void OneNeckInstallerFrm_Load(object sender, EventArgs e)
  34.         {
  35.  
  36.  
  37.             // check if BGInfo is installed
  38.             string winfold = System.Environment.GetEnvironmentVariable("windir");
  39.             string bgInfoFile = winfold + @"\BGInfo.bmp";
  40.  
  41.             if (File.Exists(bgInfoFile)) {
  42.                 lblBGInfoStatus.Text = "installed";
  43.             }
  44.             else
  45.             {
  46.                 lblBGInfoStatus.Text = "not installed";
  47.             }
  48.  
  49.  
  50.  
  51.             // check if Nagios Agent is installed
  52.             if (serviceRunning("NC_Net"))
  53.             {
  54.                 lblNagiosAgentStatus.Text = "installed";
  55.             }
  56.             else
  57.             {
  58.                 lblNagiosAgentStatus.Text = "not installed";
  59.             }
  60.  
  61.             MessageBox.Show("got this far");
  62.  
  63.             // check if SNMP is installed
  64.             if (serviceRunning("SNMP"))
  65.             {
  66.                 lblSNMPServiceStatus.Text = "installed";
  67.             } else {
  68.                 lblSNMPServiceStatus.Text = "not installed";
  69.             }
  70.             MessageBox.Show("didnt get this far");
  71.  
  72.             // check if SNARE is installed
  73.             if (serviceRunning("SNARE"))
  74.             {
  75.                 lblSnareStatus.Text = "installed";
  76.             }
  77.             else
  78.             {
  79.                 lblSnareStatus.Text = "not installed";
  80.             }
  81.  
  82.  
  83.         }
  84.         private bool serviceRunning(string serviceName)
  85.         {
  86.             bool result = false;
  87.             ServiceController sc = new ServiceController(serviceName);
  88.  
  89.             switch (sc.Status)
  90.             {
  91.                 case ServiceControllerStatus.Running:
  92.                     result = true;
  93.                     break;
  94.  
  95.                 default:
  96.                     break;
  97.             }
  98.  
  99.             return result;
  100.         }
  101.     }
  102. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement