-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsystemInventory.cs
More file actions
1241 lines (1180 loc) · 41.7 KB
/
systemInventory.cs
File metadata and controls
1241 lines (1180 loc) · 41.7 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
using System;
using System.Runtime.InteropServices;
namespace CCMClient
{
/// <summary>
/// Summary description for systemInventory.
/// </summary>
///
public class systemInventory
{
public Form1 parent;
public message mw;
public static string homeDirectory;
public int errorCount = 0;
public systemInventory(Form1 pparent)
{
//
// TODO: Add constructor logic here
//
parent = pparent;
if (homeDirectory == null)
homeDirectory = "";
if (homeDirectory.Length < 1)
homeDirectory = "C:\\";
}
public class displaySettings
{
public string refreshRate;
public string colorDepth;
public string height;
public string width;
}
public struct OSVERSIONINFO
{
public int dwOSVersionInfoSize;
public int dwMajorVersion;
public int dwMinorVersion;
public int dwBuildNumber;
public int dwPlatformId;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=128)]
public string szCSDVersion;
}
[DllImport("kernel32.Dll")]
public static extern short GetVersionEx(
ref OSVERSIONINFO o);
public string doFileChecks()
{
string retVal = "";
string results = "";
parent.fileReadStat = "";
/*
retVal += "Internet Explorer: " + fileVersionChecker(System.Environment.SystemDirectory + "\\shdocvw.dll")+"\n";
retVal += "InOrder: " + fileVersionChecker("C:\\inorder\\inorder.exe") + "\n";
retVal += "Phone Client: " + fileVersionChecker("C:\\Program Files\\Interactive Intelligence\\clientA.exe");
*/
try
{
results = readTextFile(Form1.filePath + "\\" + Form1.defFileName);
if (results.Length < 1)
parent.fileReadStat = "Definition File Load: Failed, but system did not report an error.\n";
}
catch (Exception e)
{
parent.fileReadStat = "Definition File Load: Failed: "+e.Message+"\n";
}
string[] resAr;
resAr = results.Split("\n".ToCharArray());
bool begin = false;
bool wmiBegin = false;
bool rkeyBegin = false;
bool getOS = false;
bool getdotnet = false;
bool getRR = false;
bool getM = false;
string[] wmiMin=null;
string title = "";
string path = "";
string product = "";
string key = "";
string patch = "";
string sval = "";
string search = "";
string name = "";
string wmiItem = "";
string criteria = "";
string divisor = "";
string wmiDataType = "";
string units = "";
string wmiLocation = "";
string location = "";
string[] date = null;
string[] version = null;
string[] temp;
bool required = false;
string vresult = "";
int lineNumber = 0;
Form1.debugMessage("Now checking files...");
for (int i=0;i<resAr.Length;i++)
{
if (getRR)
{
temp = resAr[i].Split("=".ToCharArray());
if (temp[0].ToLower().Trim() == "min")
parent.refreshRateMin = temp[1].Split(",".ToCharArray());
getRR = false;
}
if (getM)
{
temp = resAr[i].Split("=".ToCharArray());
if (temp[0].ToLower().Trim() == "min")
parent.memoryMin = temp[1].Split(",".ToCharArray());
getM = false;
}
if (getdotnet)
{
temp = resAr[i].Split("=".ToCharArray());
if (temp[0].ToLower().Trim() == "version")
parent.dotnetVersionStandard = temp[1].Split(",".ToCharArray());
getdotnet = false;
}
if (getOS)
{
temp = resAr[i].Split("=".ToCharArray());
if (temp[0].ToLower().Trim() == "version")
parent.osVersionStandard = temp[1].Split(",".ToCharArray());
if (temp[0].ToLower().Trim() == "sp")
parent.osSPStandard = temp[1].Split(",".ToCharArray());
getOS = false;
}
if (begin)
{
temp = resAr[i].Split("=".ToCharArray());
if (temp[0].ToLower().Trim().CompareTo("required") == 0)
if (temp[1].Trim()=="1")
required=true;
if (temp[0].ToLower().Trim().CompareTo("title") == 0)
title = temp[1].Trim();
if (temp[0].ToLower().Trim().CompareTo("name") == 0)
name = temp[1].Trim();
if (temp[0].ToLower().Trim().CompareTo("path") == 0)
path = temp[1].Trim();
if (temp[0].ToLower().Trim().CompareTo("date") == 0)
date = temp[1].Split(",".ToCharArray());
if (temp[0].ToLower().Trim().CompareTo("version")==0)
version = temp[1].Split(",".ToCharArray());
}
if (wmiBegin)
{
temp = resAr[i].Split("=".ToCharArray());
if (temp[0].ToLower().Trim().CompareTo("wmiitem") == 0)
wmiItem = temp[1].Trim();
if (temp[0].ToLower().Trim().CompareTo("criteria") == 0)
criteria = temp[1].Trim();
if (temp[0].ToLower().Trim().CompareTo("divisor") == 0)
divisor = temp[1].Trim();
if (temp[0].ToLower().Trim().CompareTo("wmidatatype") == 0)
wmiDataType = temp[1].Trim();
if (temp[0].ToLower().Trim().CompareTo("units") == 0)
units = temp[1].Trim();
if (temp[0].ToLower().Trim().CompareTo("wmilocation") == 0)
wmiLocation = temp[1].Trim();
if (temp[0].ToLower().Trim().CompareTo("min")==0)
wmiMin = temp[1].Split(",".ToCharArray());
if (temp[0].ToLower().Trim().CompareTo("title") == 0)
title = temp[1].Trim();
if (temp[0].ToLower().Trim().CompareTo("required") == 0)
if (temp[1].Trim()=="1")
required=true;
}
if (rkeyBegin)
{
temp = resAr[i].Split("=".ToCharArray());
if (temp[0].ToLower().Trim().CompareTo("path") == 0)
path = temp[1].Trim();
if (temp[0].ToLower().Trim().CompareTo("sval") == 0)
sval = temp[1].Trim();
if (temp[0].ToLower().Trim().CompareTo("product") == 0)
product = temp[1].Trim();
if (temp[0].ToLower().Trim().CompareTo("key") == 0)
key = temp[1].Trim();
if (temp[0].ToLower().Trim().CompareTo("location") == 0)
location = temp[1].Trim();
if (temp[0].ToLower().Trim().CompareTo("patch") == 0)
patch = temp[1].Trim();
if (temp[0].ToLower().Trim().CompareTo("version") == 0)
version = temp[1].Split(",".ToCharArray());
if (temp[0].ToLower().Trim().CompareTo("title") == 0)
title = temp[1].Trim();
if (temp[0].ToLower().Trim().CompareTo("search") == 0)
search = temp[1].Trim();
if (temp[0].ToLower().Trim().CompareTo("required") == 0)
if (temp[1].Trim()=="1")
required=true;
}
if (resAr[i].ToLower().Trim().CompareTo("<dotnet>") == 0)
getdotnet=true;
if (resAr[i].ToLower().Trim().CompareTo("</dotnet>") == 0)
getdotnet=false;
if (resAr[i].ToLower().Trim().CompareTo("<refresh rate>") == 0)
getRR=true;
if (resAr[i].ToLower().Trim().CompareTo("</refresh rate>") == 0)
getRR=false;
if (resAr[i].ToLower().Trim().CompareTo("<memory>") == 0)
getM=true;
if (resAr[i].ToLower().Trim().CompareTo("</memory>") == 0)
getM=false;
if (resAr[i].ToLower().Trim().CompareTo("<os>") == 0)
getOS=true;
if (resAr[i].ToLower().Trim().CompareTo("</os>") == 0)
getOS=false;
if (resAr[i].ToLower().Trim().CompareTo("<rkey>") == 0)
rkeyBegin = true;
if (resAr[i].ToLower().Trim().CompareTo("</rkey>") == 0)
{
rkeyBegin = false;
vresult = regCheck(path,product,key,patch,sval,version,location);
if (search.Length > 0)
{
if ((vresult.ToLower().Trim().IndexOf(search.ToLower().Trim(),0,vresult.Length)) == -1)
{
vresult = "Search value not found";
if (required)
{
errorCount++;
vresult += " ---bad--- This is a required component.";
}
}
else
vresult = "Installed";
}
if (vresult.Length < 1)
{
vresult = "Not Installed";
if (required)
{
errorCount++;
vresult += " ---bad--- This is a required component.";
}
}
retVal += "\n"+ title + ": " + vresult;
search = "";
vresult = "";
key = "";
product = "";
path = "";
patch="";
location="";
version = null;
sval="";
required = false;
title = "";
}
if (resAr[i].ToLower().Trim().CompareTo("<wmi>") == 0)
wmiBegin = true;
if (resAr[i].ToLower().Trim().CompareTo("</wmi>") == 0)
{
wmiBegin = false;
Form1.debugMessage("Checking WMI result..." + wmiDataType + "-" + wmiLocation+ "-" +wmiItem+ "-" +criteria+ "-" +divisor);
if (wmiItem.Length > 0 && wmiLocation.Length > 0)
vresult = wmiQuery(wmiLocation,wmiItem,criteria,divisor);
if (wmiDataType.CompareTo("DateTime") == 0)
{
Form1.debugMessage("Fixing DateTime on: " + vresult);
vresult = fixDateTime(vresult).ToString();
}
else
Form1.debugMessage("WOOPS:" + wmiDataType);
if (wmiMin != null)
if (wmiMin.Length > 0)
try
{
vresult = vresult + units + checkMin(wmiItem,vresult,wmiMin);
}
catch (Exception e)
{
//MessageBox.Show(e.Message);
}
else
vresult += units;
if (required)
if (vresult.Length < 1 || (vresult.CompareTo("Not Found") == 0))
{
errorCount++;
vresult = "Not Found ---bad--- This is a required component";
}
retVal += "\n"+ title + ": " + vresult;
//fileReadStat += "Definition File: " + retVal + "\n";
title = "";
path = "";
divisor="";
units="";
name = "";
wmiItem = "";
wmiDataType="";
wmiLocation = "";
criteria = "";
wmiMin = null;
version = null;
date = null;
required=false;
}
if (resAr[i].ToLower().Trim().CompareTo("<file>") == 0)
{
begin=true;
//fileReadStat += "BON\n";
}
string sep = "\\";
if (resAr[i].ToLower().Trim().CompareTo("</file>") == 0)
{
begin = false;
if (name.IndexOf("*",0,name.Length)>-1)
{
name=getNewestFile(name,path.Replace("%windir%",System.Environment.SystemDirectory));
path="";
sep = "";
}
vresult = fileVersionChecker(path.Replace("%windir%",System.Environment.SystemDirectory)+sep + name,true,version,date);
if (required)
if (vresult.Length < 1 || (vresult.CompareTo("Not Found") == 0))
{
errorCount++;
vresult = "Not Found ---bad--- This is a required component";
}
retVal += "\n"+ title + ": " + vresult;
//fileReadStat += "Definition File: " + retVal + "\n";
title = "";
path = "";
name = "";
version = null;
date = null;
required=false;
}
//retVal += resAr[i];
}
return retVal;
}
public string fileVersionChecker(string tfile)
{
return fileVersionChecker(tfile,false,null,null);
}
public string getNewestFile(string name,string path)
{
string[] myfiles;
string retVal = "";
DateTime dt = new DateTime();
DateTime dt2;
int lineNum=0;
string[] extensions = name.Split(',');
string[] paths = path.Split(',');
try
{
lineNum=1;
//System.Windows.Forms.MessageBox.Show(extensions.Length.ToString());
for(int idx=0;idx<extensions.Length;idx++)
{
//System.Windows.Forms.MessageBox.Show(name + " - " + extensions[idx]);
if (paths.Length == extensions.Length)
path=paths[idx];
if (System.IO.Directory.Exists(path))
{
lineNum=2;
myfiles=System.IO.Directory.GetFiles(path,extensions[idx]);
lineNum=3;
//System.Windows.Forms.MessageBox.Show(path + " - " + extensions[idx] + " - " + myfiles.Length);
if (myfiles.Length > 0)
if (idx > 0)
{
if (System.IO.Directory.GetLastWriteTime(myfiles[0]) > dt)
{
dt = System.IO.Directory.GetLastWriteTime(myfiles[0]);
name = myfiles[0];
}
}
else
{
dt = System.IO.Directory.GetLastWriteTime(myfiles[0]);
name = myfiles[0];
}
for(int i=1;i<myfiles.Length;i++)
{
dt2 = System.IO.Directory.GetLastWriteTime(myfiles[i]);
if (dt2 > dt)
{
name = myfiles[i];
//System.Windows.Forms.MessageBox.Show(name + " - " + extensions[idx]);
dt = dt2;
}
}
retVal = name; //.Replace(path,"");
//System.Windows.Forms.MessageBox.Show("USING THIS: " + name + " " + idx.ToString());
}
}
}
catch (Exception e)
{
// System.Windows.Forms.MessageBox.Show("getNewestFile error: " + e.Message +"\n"+ e.StackTrace);
Form1.debugMessage("getNewestFile error: " + e.Message +"\n"+ e.StackTrace);
retVal = "";
}
//System.Windows.Forms.MessageBox.Show("USING THIS: " + retVal);
return retVal;
}
public string fileVersionChecker(string tfile,bool check,string[] FileVersion,string[] Date)
{
Form1.debugMessage("File Version Checker..." + tfile + " " + check);
string retVal = "";
string fdate = "";
try
{
fdate = new System.IO.FileInfo(tfile).LastWriteTime.ToShortDateString() + "";
retVal += System.Diagnostics.FileVersionInfo.GetVersionInfo(tfile).FileVersion + " - " + fdate ;
if (check)
{
if (FileVersion != null)
if (!checkVer(System.Diagnostics.FileVersionInfo.GetVersionInfo(tfile).FileVersion,FileVersion))
{
errorCount++;
retVal += "\n---badVersion---\n-Yours:["+System.Diagnostics.FileVersionInfo.GetVersionInfo(tfile).FileVersion+"] Standard:["+showA(FileVersion)+"]";
}
if (Date != null)
if (!checkVer(fdate,Date))
{
errorCount++;
retVal += "\n---badDate---\n-Yours:["+fdate+"] Standard:["+showA(Date)+"]";
}
}
}
catch (Exception e) { retVal += "Not Found"; }
Form1.debugMessage("DONE! File Version Checker..." + tfile + " " + check);
return retVal;
}
public static string readTextFile(string name)
{
return readTextFile(name,false);
}
public static string readTextFile(string name,bool forceDebugSkip)
{
string results = "";
System.IO.FileInfo dataFile;
System.IO.StreamReader textStream;
dataFile = new System.IO.FileInfo(name);
textStream = dataFile.OpenText();
if (!forceDebugSkip)
Form1.debugMessage("Starting to read " + name + ".");
results += textStream.ReadToEnd();
if (!forceDebugSkip)
Form1.debugMessage("Done reading " + name + ".\n-------\n" + results );
textStream.Close();
/* System.IO.FileStream myFile = System.IO.File.Open(name,System.IO.FileMode.Open,System.IO.FileAccess.Read,System.IO.FileShare.Read);
for (int i=0;i<myFile.Length;i++)
results += (char)myFile.ReadByte();
myFile.Close(); */
return results;
}
public string implode(string[] var, string sep)
{
string retVal = "";
string spacer = "";
for (int i=0;i<var.Length;i++)
{
retVal += spacer + var[i];
spacer = sep + " ";
}
return retVal;
}
private String wmiQuery(string location, string item)
{
return wmiQuery(location,item,"","");
}
private String wmiQuery(string location, string item, string criteria,string divisor)
{
Form1.debugMessage("WMI Query..." + location + " " + item + " " + criteria + " " + divisor);
String retVal = "";
String tq = "";
int loopCount = 0;
int lineCount = 0;
try
{
String sep = "";
String temp = "";
float mydiv = 0;
float holder = 0;
try
{
mydiv = float.Parse(divisor);
}
catch (Exception e){}
tq = "Select * from " + location;
if (criteria.Length > 0)
tq += " where " + criteria.Replace(" is ","=");
//MessageBox.Show(tq);
System.Management.ManagementObjectCollection queryCollection = null;
Form1.debugMessage("WMI Query: " + tq);
System.Management.ManagementObjectSearcher searcher = new System.Management.ManagementObjectSearcher(tq) ;
Form1.debugMessage("Getting WMI Collection: " + tq);
lineCount = 1;
queryCollection = searcher.Get();
lineCount = 2;
// if (queryCollection.Count < 1) //THIS MAKES THINGS BREAK :-(
// Form1.debugMessage("Nothing Returned for Query: " + location + " " + item + " " + criteria + " " + divisor);
lineCount = 3;
foreach( System.Management.ManagementObject mo in queryCollection )
{
loopCount++;
Form1.debugMessage("ITEM ... " + location + " " + item + " " + criteria + " " + divisor);
if (mo[item] != null)
{
try
{
temp = mo[item].ToString();
Form1.debugMessage("Got Value:" + temp + "[" + location + " " + item + " " + criteria + " " + divisor + "]");
//MessageBox.Show(sep + temp.Replace(":","%colon%"));
if (mydiv != 0)
{
holder=0;
try
{
holder = float.Parse(temp);
}
catch (Exception e){}
holder = holder/mydiv;
temp = System.Math.Round(holder,3).ToString();
}
if (temp.Length > 0)
retVal += sep + temp; //.Replace(":","%colon%");
}
catch (Exception e)
{
Form1.debugMessage("WMI Query Error 1 ("+loopCount+") ..." + e.Message + "\n" + location + " " + item + " " + criteria + " " + divisor + "\n" + e.Source + "\n" + e.StackTrace);
retVal += sep + e.Message;
}
}
else
Form1.debugMessage("WMI Query returned a null. " + location + " " + item + " " + criteria + " " + divisor);
lineCount = 4;
sep = ", ";
lineCount = 5;
}
}
catch (Exception e)
{
Form1.debugMessage("WMI Query Error 2("+loopCount+"-"+lineCount+") ..." + e.Message + "\n" + location + " " + item + " " + criteria + " " + divisor + "\n" + e.Source + "\n" + e.StackTrace);
retVal += e.Message + "*" + tq;
}
Form1.debugMessage("Done WMI Query..." + location + " " + item + " " + criteria + " " + divisor);
return retVal;
}
private String getMemory()
{
return wmiQuery("Win32_ComputerSystem","totalphysicalmemory");
}
public float getColorDepth()
{
displaySettings[] ds = getScreenInfo();
//System.Windows.Forms.MessageBox.Show("-->" + ds.Length + ds[0].colorDepth);
return this.strToFloat(ds[0].colorDepth);
}
public displaySettings[] getScreenInfo()
{
int i = 0;
System.Management.ManagementObjectSearcher searcher = new System.Management.ManagementObjectSearcher("select * from win32_videocontroller");
foreach (System.Management.ManagementObject videocontroller in searcher.Get())
{
if (videocontroller["CurrentRefreshRate"] != null)
i++;
}
displaySettings[] myDS = new displaySettings[i];
i=0;
foreach (System.Management.ManagementObject videocontroller in searcher.Get())
{
if (videocontroller["CurrentRefreshRate"] != null)
{
myDS[i] = new displaySettings();
myDS[i].colorDepth=""+videocontroller["CurrentNumberOfColors"];
myDS[i].refreshRate=""+videocontroller["CurrentRefreshRate"];
myDS[i].height=""+videocontroller["CurrentVerticalResolution"];
myDS[i].width=""+videocontroller["CurrentHorizontalResolution"];
i++;
}
}
return myDS;
}
public void updateAppLog()
{
updateAppLog(this.mw);
}
public void updateAppLog(message messageWindow)
{
string updates = "-------------APPLOG----------------\n" + parent.applicationLog;
updates = updates.Replace("-------------APPLOG----------------","\\b\\cf0\\fs30 Application Log: \\b0\\cf0\\fs16");
updates = updates.Replace("\n","\n\\b\\cf1");
updates = updates.Replace(":"," : \\b0\\cf1");
updates = updates.Replace("\n","\\par\n");
updates = updates.Replace("Error","\\b\\cf2 Error \\b0\\cf1");
updates = updates.Replace("Information","\\b\\cf3 Information \\b0\\cf1");
updates = updates.Replace("Warning","\\b\\cf4 Warning \\b0\\cf1");
updates = updates.Replace("#C#",":");
messageWindow.appLogBox.Rtf="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fswiss\\fcharset0 Arial;}}\n{\\colortbl ;\\red0\\green0\\blue0;\\red255\\green0\\blue0;\\red0\\green255\\blue0;\\red0\\green0\\blue255;}\n\\viewkind4\\uc1\\pard\\cf1\\f0\\fs16 "+updates+"\\cf0\\b0\\par\n}";
}
public void updateSysLog()
{
updateSysLog(this.mw);
}
public void updateSysLog(message messageWindow)
{
string updates = "-------------SYSLOG----------------\n" + parent.systemLog;
updates = updates.Replace("-------------SYSLOG----------------","\\b\\cf0\\fs30 System Log: \\b0\\cf0\\fs16");
updates = updates.Replace("\n","\n\\b\\cf1");
updates = updates.Replace(":"," : \\b0\\cf1");
updates = updates.Replace("\n","\\par\n");
updates = updates.Replace("Error","\\b\\cf2 Error \\b0\\cf1");
updates = updates.Replace("Information","\\b\\cf3 Information \\b0\\cf1");
updates = updates.Replace("Warning","\\b\\cf4 Warning \\b0\\cf1");
updates = updates.Replace("#C#",":");
messageWindow.sysLogBox.Rtf="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fswiss\\fcharset0 Arial;}}\n{\\colortbl ;\\red0\\green0\\blue0;\\red255\\green0\\blue0;\\red0\\green255\\blue0;\\red0\\green0\\blue255;}\n\\viewkind4\\uc1\\pard\\cf1\\f0\\fs16 "+updates+"\\cf0\\b0\\par\n}";
}
public void updateUpdates()
{
updateUpdates(this.mw);
}
public void updateUpdates(message messageWindow)
{
string updates = "-------------UPDATE HISTORY----------------\n" + parent.updateHistory;
updates = updates.Replace("-------------UPDATE HISTORY----------------","\\b\\cf0\\fs30 Updates & Messages Recieved: \\b0\\cf0\\fs16");
updates = updates.Replace("\n","\n\\b\\cf1");
updates = updates.Replace(":"," : \\b0\\cf1");
updates = updates.Replace("\n","\\par\n");
messageWindow.updatesBox.Rtf="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fswiss\\fcharset0 Arial;}}\n{\\colortbl ;\\red0\\green0\\blue0;\\red255\\green0\\blue0;}\n\\viewkind4\\uc1\\pard\\cf1\\f0\\fs16 "+updates+"\\cf0\\b0\\par\n}";
}
public string showA(string[] mystring)
{
string retVal = "";
string sep = "";
for(int i=0;i<mystring.Length;i++)
{
retVal += sep + mystring[i].Trim();
sep = ",";
}
return retVal;
}
public bool checkVer(string who, string[] what)
{
Form1.debugMessage("checkVerStart");
bool checkIt = false;
for (int i=0;i<what.Length;i++)
if (who.ToString().ToLower().Trim() == what[i].ToLower().Trim())
checkIt = true;
Form1.debugMessage("checkVerStop");
return checkIt;
}
private string getProcessor()
{
String retVal = "";
Object val = Form1.getRegVal("VendorIdentifier","HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0");
retVal = val.ToString();
val = Form1.getRegVal("Identifier","HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0");
retVal += " " + val.ToString();
return retVal;
}
public string getInstalledSoftware()
{
return getInstalledSoftware(true);
}
public string getInstalledSoftware(bool type)
{
string retVal = "";
string holder = "";
string[] listOfSubKeys;
Microsoft.Win32.RegistryKey pRegKey2;
string path = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\";
Microsoft.Win32.RegistryKey pRegKey = Microsoft.Win32.Registry.LocalMachine;
pRegKey = pRegKey.OpenSubKey(path);
if (pRegKey != null)
{
listOfSubKeys = pRegKey.GetSubKeyNames();
for (int i=0;i<listOfSubKeys.Length;i++)
{
if (listOfSubKeys[i].StartsWith("{") ^ type)
{
pRegKey2 = pRegKey.OpenSubKey(listOfSubKeys[i]);
holder = "";
if (pRegKey2.GetValue("DisplayName") != null)
holder = pRegKey2.GetValue("DisplayName").ToString();
if (holder.Length < 1)
holder = listOfSubKeys[i];
retVal += holder;
if (pRegKey2.GetValue("DisplayVersion") != null)
if (pRegKey2.GetValue("DisplayVersion").ToString().Length > 0)
retVal += " - " + pRegKey2.GetValue("DisplayVersion");
retVal += "\n";
}
}
}
return retVal;
}
public string getVersionInfo()
{
string retVal = "";
string fChecks = "";
string spInfo = "";
string err = "";
string[] stuff;
errorCount = 0;
try
{
fChecks += doFileChecks();
}
catch (Exception e) {
Form1.debugMessage("FILE CHECK ERROR..." + e.Message + "\n" + e.Source + "\n" + e.StackTrace);
}
Form1.debugMessage("Now getting system info...");
OSVERSIONINFO os = new OSVERSIONINFO();
os.dwOSVersionInfoSize=Marshal.SizeOf(typeof(OSVERSIONINFO));
GetVersionEx(ref os);
if (os.szCSDVersion=="")
spInfo = "No Service Pack Installed";
else
spInfo = os.szCSDVersion;
OperatingSystem os2 = System.Environment.OSVersion;
if (!checkVer(os2.ToString()+" ("+spInfo+")",parent.osVersionStandard))
{
errorCount++;
err = "---bad version---\nYours:["+os2.ToString()+" ("+spInfo+")] Standard:["+showA(parent.osVersionStandard)+"]";
}
//if (!checkVer(spInfo,osSPStandard))
//err = "---bad service pack---\nYours:["+spInfo+"] Standard:["+showA(osSPStandard)+"]";
retVal += "Timestamp: " + System.DateTime.Now.ToShortDateString() + " " + System.DateTime.Now.ToShortTimeString() + "\n";
retVal += "Windows: " + parent.SplitByString(os2.ToString(),"Service Pack")[0].ToString() + " (" + spInfo + ") "+err+"\n";
err="";
Form1.debugMessage("Getting Processor Info...");
retVal += "Processor: " + getProcessor() +"\n";
err = "";
string holder="";
//holder = getMemory();
//if (strToInt(holder) < strToInt(memoryMin[0].Trim()))
// err = "---bad Memory Size---\nYours:["+holder+"] Standard Minimum:["+memoryMin[0].Trim()+"]";
//retVal += "Memory: " + holder + err + "\n";
err = "";
holder = "";
retVal += "\nIBS Workstation: " + Form1.cver +"\n";
Form1.debugMessage("Getting DotNet Version...");
if (!checkVer(System.Environment.Version.ToString(),parent.dotnetVersionStandard))
{
errorCount++;
err = "---bad version---\nYours:["+System.Environment.Version.ToString()+"] Standard:["+showA(parent.dotnetVersionStandard)+"]";
}
retVal += "dotNet Version: " + System.Environment.Version.ToString()+err+"\n";
err = "";
retVal += "Auto Update: " + parent.autoUpdate.Checked.ToString() +"\n";
retVal += "Enter = Send: " + parent.enterSend.Checked.ToString() +"\n";
retVal += "Auto Hide: " + parent.autoHide.Checked.ToString() +"\n";
retVal += "Disable Pops: " + parent.disablePops.Checked.ToString() +"\n";
DateTime startTime = parent.startTime;
retVal += "Workstation Started: " + startTime.ToShortDateString() + " " + startTime.ToShortTimeString() + "\n";
//if (System.Environment.CommandLine.ToString().ToLower().IndexOf("isaac\\ibsworkstation") < 1)
//{
// errorCount++;
// err = "---bad source location---\nYours:["+System.Environment.CommandLine.ToString()+"] Standard:[\\\\isaac\\ibsWorkstation\\IBSWorkstation.exe]";
//}
retVal += "Command Line: " + System.Environment.CommandLine.ToString() +err+"\n";
retVal += "Path: " + Form1.controlPath + err + "\n";
err = "";
retVal += "\nUser: " + Form1.getCurrentUser() +"\n";
string ls = "Not Logged In";
string sid = "";
if (Form1.loggedIn)
ls = "Logged In";
try
{
sid = Form1.getRegVal("ProfileImagePath","Software\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList\\" + SID.ShowUserSID(Form1.currentUser)).ToString();
if (sid.Length > 1)
{
homeDirectory = sid;
Form1.setRegVal("homeDirectory",sid);
}
else
{
sid = Form1.getRegVal("homeDirectory").ToString();
if (sid.Length > 1)
homeDirectory = sid;
}
retVal += "Home Directory: " + homeDirectory + "\n";
}
catch (Exception e)
{
Form1.debugMessage(e.Message + "\n" + Form1.currentUser);
string ret = "";
sid = "C:\\Documents and Settings\\" + Form1.currentUser.ToLower().Replace("us_ibs\\","");
Form1.debugMessage("Trying " + sid);
if (System.IO.Directory.Exists(sid)){
ret = sid;
}
else
{
string sid2 = sid + ".US_IBS";
Form1.debugMessage("Trying " + sid2);
if (System.IO.Directory.Exists(sid2))
ret = sid2;
else
{
sid2 = sid + ".ibs.org";
Form1.debugMessage("Trying " + sid2);
if (System.IO.Directory.Exists(sid2))
ret = sid2;
else
{
sid2 = sid + ".ibs";
Form1.debugMessage("Trying " + sid2);
if (System.IO.Directory.Exists(sid2))
ret = sid2;
else
{
sid2 = sid + ".WINNT";
Form1.debugMessage("Trying " + sid2);
if (System.IO.Directory.Exists(sid2))
ret = sid2;
else
{
ret = "C:\\";
Form1.debugMessage("Gave up using: " + ret);
}
}
}
}
}
retVal += "Home Directory: " + ret + "\n";
homeDirectory = ret;
Form1.setRegVal("homeDirectory",ret);
}
retVal += "Login Status: " + ls +"\n";
retVal += "Program Context: " + System.Environment.UserName +"\n";
retVal += "Computer: " + System.Environment.MachineName +"\n";
retVal += "Hostname: " + System.Net.Dns.GetHostName() + "\n";
retVal += "IP Address: " + getIPAddress() + "\n";
//retVal += "Last Reboot: " + ((float)((uint)System.Environment.TickCount)/1000/60/60/24) +" days ago.\n";
//retVal += "Last Reboot: " + lastSystemBootUp.getSystemBootup().ToString() + "\n";
//retVal += "Last Reboot (simple): " + wmiQuery("Win32_OperatingSystem","LastBootUpTime") + "\n";
err="";
displaySettings [] dps = getScreenInfo();
// if (rr.CompareTo(refreshRateMin[0]) > 1)
string sep="";
for (int i=0;i<dps.Length;i++)
{
holder += sep + dps[i].refreshRate;
sep = ",";
}
stuff = holder.Split(",".ToCharArray());
for (int i=0;i<stuff.Length;i++)
if (strToInt(stuff[i]) < strToInt(parent.refreshRateMin[0]))
{
errorCount++;
err = "---bad Refresh Rate---\nYours:["+holder+"] Standard:["+parent.refreshRateMin[0].Trim()+"]";
}
retVal += "Refresh Rate: " + holder + err + "\n";
retVal += "Screen Resolution: ";
sep = "";
for (int idx=0;idx<dps.Length;idx++)
{
retVal+= sep + dps[idx].width + "x" + dps[idx].height + "x" + dps[idx].colorDepth;
sep = ",";
}
retVal += "\n";
retVal += parent.fileReadStat;
retVal += fChecks;
retVal += "\nError Count: " + errorCount;
Form1.debugMessage("Getting Update History...");
eventLog eLog = new eventLog();
if (parent.updateHistory.Length > 0)
{
retVal += "\n-------------UPDATE HISTORY----------------";
retVal += parent.updateHistory;
}
//retVal += "\n-------------Application Log----------------\n";
parent.applicationLog = eLog.viewLog("Application",300);
//retVal += "\n-------------System Log----------------\n";
parent.systemLog = eLog.viewLog("System",300);
parent.directoryLog = eLog.viewLog("Directory Service",300);
parent.frsLog = eLog.viewLog("File Replication Service",300);
Form1.debugMessage("Finishing Up...");
return retVal;
}
public string regCheck(string path, string product,string key,string patch,string sval,string[] version, string location)
{
Form1.debugMessage("Reg Key Searching..." + path + " " + product + " " + key + " " + patch + " " + sval);
string retVal = "";
if (sval.Length < 1)
sval = "InstalledDate";
if (path.Length < 1)
path = "Software\\Microsoft\\Updates\\";
Microsoft.Win32.RegistryKey pRegKey;
if (location.ToUpper().CompareTo("HKEY_CURRENT_USER") == 0)
pRegKey = Microsoft.Win32.Registry.CurrentUser;
else if (location.ToUpper().CompareTo("HKEY_USERS") == 0)
pRegKey = Microsoft.Win32.Registry.Users;
else if (location.ToUpper().CompareTo("HKEY_CURRENT_CONFIG") == 0)
pRegKey = Microsoft.Win32.Registry.CurrentConfig;
else if (location.ToUpper().CompareTo("HKEY_CLASSES_ROOT") == 0)
pRegKey = Microsoft.Win32.Registry.ClassesRoot;
else
pRegKey = Microsoft.Win32.Registry.LocalMachine;
pRegKey = pRegKey.OpenSubKey(path+product+"\\"+key+"\\"+patch);
Form1.debugMessage("Getting..." +path+product+"\\"+key+"\\"+patch+ "--- " + sval);
if (pRegKey != null)
{
if (sval == "InstalledDate")
retVal = pRegKey.GetValue("Description") + " - ";
retVal += pRegKey.GetValue(sval);
Form1.debugMessage("...Got : " + retVal);
try
{
if (version.Length > 0)
{
bool matched = false;
for(int j=0; j < version.Length; j++)
{
if (version[j].Trim() == pRegKey.GetValue(sval).ToString())
matched = true;
}
if (!matched)
{
errorCount++;
retVal += "---bad Version---\nYours: ["+pRegKey.GetValue(sval)+"] Standard: ["+implode(version,",")+"]";
}
}
}
catch (Exception e)
{
}
Form1.debugMessage("DONE! Reg Key Searching..." + path + " " + product + " " + key + " " + patch + " " + sval);
return retVal;
}
return "";
}
public int strToInt(string val)
{
int myInt = 0;
try { myInt=int.Parse(val); }
catch(Exception e) { }
return myInt;
}
public float strToFloat(string val)
{
float myInt = 0;
try { myInt=float.Parse(val); }
catch(Exception e) { }
return myInt;
}
public string checkMin(string item, string mine, string[] standard)
{
string retVal = "";
string[] holder = mine.Split(",".ToCharArray());
for(int i=0; i < holder.Length; i++)
for(int j=0; j < standard.Length; j++)
if (strToFloat(holder[i]) < strToFloat(standard[j].Trim()))
{
errorCount++;
retVal = "---bad "+item+"---\nYours:["+mine+"] Standard Minimum:["+standard[j].Trim()+"]";
}
return retVal;
}
public void updateMessageWindow()
{
updateMessageWindow(this.mw);