~siggi-bjarnason/siggivbscript/vbscript

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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
6061
6062
6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
6084
6085
6086
6087
6088
6089
6090
6091
6092
6093
6094
6095
6096
6097
6098
6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
REM ### Script: W2Kupdate
REM ### ScriptVersion: 2.2
REM ### Created: 2/14/2000
REM ### Modified: 9/25/2000
REM ### Group: Global Infrastructure Services
REM ### Contact: Doug Young
REM ### Description: Used to upgrade software on Windows 2000 servers at Microsoft.



REM ##################################################################################################
REM ######             Declare and set variables and Definitions for the script                 ######
REM #############d####################################################################################
REM ###### Declare variables ######
option explicit
dim arg
dim Wshshell, Wshnetwork, Wshmapdrives, Wshfile
dim computername, systemdrive, systemroot, backuproot, procarc, numproc, path, userdomain, username, tempdir
dim begdate, begtime, enddate, endtime, regarray(100,4), regarrayloc, netfactor, cdrunvar
dim bypass, debug, forceupdate, locationtestvar, argtext, okargtext, srvdebug

dim alldrives, harddrives, netdrives, cddrives, allservices, extraservices

dim scriptnamevar, scriptversionvar, scriptipakvar, scriptosvervar, scriptarcvar, scriptbuildvar
dim scriptbinvar, scripttempvar, scriptlogvar, scriptrebootvar, scripttsvar
dim scriptsitevar, scriptconswivar, scriptnetworkvar
dim scriptpathlocvar, scriptcmdlocvar, scriptinilocvar, scriptfileslocvar
dim scriptsharelocvar, scriptdrivelocvar, scriptserverlocvar, scriptbinlocvar, scriptloglocvar

dim srvvervar, srvbuildvar, srvcsdvar, srvarcvar, srvrolevar, srvsuitevar, srvencvar, srvdomainvar, srvdomtypevar
dim srvhardwarevar, srvhardtypevar, srvbootvar, srvmemvar, srvstrwrksvar

dim spvar, spchkvar, spfilevar, spdirvar, splocvar, splogvar
dim fixvar, fixlocvar, fixlogvar
dim symvar, symlocvar, symfulllocvar, symlogvar
dim encvar, enclocvar, enclogvar

dim wwwvar, wwwlogvar, wwwlocvar, wwwsymlocvar
dim termvar, sqlvar, exchangevar, sapvar

dim cpqbiosdate, cpqssdvar, cpqssdchkvar, cpqssdfilevar, cpqssdlogvar, cpqssdlocvar
dim cpqcimvar, cpqcimchkvar, cpqcimfilevar, cpqcimlogvar, cpqcimlocvar
dim cpqstrdrvvar, cpqstrdrvchkvar, cpqstrdrvfilevar, cpqstrdrvlogvar, cpqstrdrvlocvar
dim delbiosdate, delmannvar, delmannchkvar, delmannfilevar, delmannlogvar, delmannlocvar
dim delfastvar, delfastchkvar, delfastfilevar, delfastlogvar, delfastlocvar
dim deldrvvar, deldrvchkvar, deldrvfilevar, deldrvlogvar, deldrvlocvar

dim bldvar, bldlocvar
dim recconsvar, recconschkvar, recconsfilevar, recconslogvar, recconslocvar
dim opavar, opachkvar, opafilevar, opalogvar, opalocvar
dim senvar, senchkvar, senfilevar, senlogvar, senlocvar
dim niqvar, niqchkvar, niqfilevar, niqlogvar, niqlocvar
dim inocvar, inocchkvar, inocfilevar, inoclogvar, inoclocvar
dim oicvar, oicchkvar, oicfilevar, oiclogvar, oiclocvar
dim bacvar, bacchkvar, bacfilevar, baclogvar, baclocvar



REM ###### Set definitions ######
Set Wshnetwork = Wscript.CreateObject("Wscript.Network")
Set Wshshell = Wscript.CreateObject("Wscript.shell")
Set Wshfile = Wscript.CreateObject("Scripting.FileSystemObject")
computername = WshShell.ExpandEnvironmentStrings("%COMPUTERNAME%")
systemdrive = WshShell.ExpandEnvironmentStrings("%SYSTEMDRIVE%")
systemroot = WshShell.ExpandEnvironmentStrings("%SYSTEMROOT%")
procarc = WshShell.ExpandEnvironmentStrings("%PROCESSOR_ARCHITECTURE%")
numproc = WshShell.ExpandEnvironmentStrings("%NUMBER_OF_PROCESSORS%")
path = WshShell.ExpandEnvironmentStrings("%PATH%")
username = WshShell.ExpandEnvironmentStrings("%USERNAME%")
userdomain = WshShell.ExpandEnvironmentStrings("%USERDOMAIN%")
tempdir = WshShell.ExpandEnvironmentStrings("%TEMP%")

REM ###### Set script variables ######
scriptnamevar = left(wscript.ScriptName, Instr(1, wscript.ScriptName, ".vbs", 1) -1)
scriptversionvar = "2.2"
scriptipakvar = "NT5.02"
scriptosvervar = "5.0"
scriptarcvar = "x86"
scriptbuildvar = 2195
scriptbinvar = systemdrive & "\localbin"
scripttempvar = systemdrive & "\temp\" & scriptnamevar
scriptlogvar = systemroot & "\ipaklogs"
scriptrebootvar = "ask"
scripttsvar = "no"
scriptloglocvar = "\\cpitgfsa02\scriptlogs"
srvdebug = 0
debug = 0
regarrayloc = 1
forceupdate = 0
locationtestvar = 0
netfactor = 1
cdrunvar = "off"
bypass = "\\cpitgddsa01\gmas\bronze\ipak\nt5.02"
okargtext = ",/com,/del,/oth,/nostrwrk,/allfixes,/fullsym,/clrsym,/noupd,"
okargtext = okargtext & "/reb,/noreb,/debug,/forceup,/nobitmap,/slownet,"
okargtext = okargtext & "/inocon,/buacon,/nocim,/noopa,/nosen,/noniq,/noinoc,/nooic,/nobac,/notools,/new,"
okargtext = okargtext & "/wwwreg,/sqlreg,/excreg,/sapreg,/wwwipak,-?,/?,"
okargtext = okargtext & "head,paths,auth,config,locs,check,path,defpath,bug,scriptbug,noscriptbug,loctest,"
okargtext = okargtext & "notas,noots,noall,build,sp,nontbuilds,strtest,forcecd,128bit,"

REM ###### IPAK variables ######
bldvar = "on"
recconsvar = "1.0"
recconschkvar = systemdrive & "\cmdcons\autochk.exe"
recconsfilevar = ""
recconslogvar = ""
spvar = "1"
spdirvar = "SP1"
spchkvar = systemroot & "\system32\cmd.exe"
spfilevar = "7/21/2000"
splogvar = ""
fixvar = "on"
fixlogvar = ""
symvar = "small"
symlogvar = ""
encvar = "on"
enclogvar = ""

REM ###### Set hardware software variables ######
cpqbiosdate = "8/17/1998"
cpqssdvar = "5.03a"
cpqssdchkvar = systemroot & "\system32\drivers\sysmgmt.sys"
cpqssdfilevar = "6/1/2000"
cpqssdlogvar = ""
cpqcimvar = "4.80"
cpqcimchkvar = systemroot & "\system32\cpqmgmt\CqMgServ\CqMgServ.exe"
cpqcimfilevar = "5/30/2000"
cpqcimlogvar = ""
cpqstrdrvvar = "5-4.41A5"
cpqstrdrvchkvar = systemroot & "\system32\drivers\cpqkgpsa.sys"
cpqstrdrvfilevar = "1/31/2000"
cpqstrdrvlogvar = ""
delbiosdate = "10/27/1999"
delmannvar = "1.52"
delmannchkvar = systemdrive & "\program files\dell\OpenManage\nnm-HIP\bin\dcbase.exe"
delmannfilevar = "12/29/1999"
delmannlogvar = ""
delfastvar = "2.1-2972"
delfastchkvar = systemdrive & "\program files\perc2\afa\afaagent.exe"
delfastfilevar = "7/7/2000"
delfastlogvar = ""
deldrvvar = "2.1-2963"
deldrvchkvar = systemroot & "\system32\drivers\perc2.sys"
deldrvfilevar = "4/7/2000"
deldrvlogvar = ""

REM ###### Set tool variables ######
opavar = "3.0"
opachkvar = systemdrive & "\program files\opassist\opassist.exe"
opafilevar = "2/8/2000"
opalogvar = ""
senvar = "2.5.2.7"
senchkvar = systemdrive & "\sentry\progs\sass.exe"
senfilevar = "9/2/1998"
senlogvar = ""
niqvar = "3.0.361.8"
niqchkvar = systemdrive & "\netiq\bin\netiqmc.exe"
niqfilevar = "2/3/1999"
niqlogvar = ""
inocvar = "375"
inocchkvar = systemroot & "\system32\drivers\ino_fltr.sys"
inocfilevar = "3/7/2000"
inoclogvar = ""
oicvar = "2"
oicchkvar = systemdrive & "\oic\ObjectInactivityService.exe"
oicfilevar = "7/27/1999"
oiclogvar = ""
bacvar = "8.x"
bacchkvar = systemdrive & "\bentaa\beremote.exe"
bacfilevar = "4/20/2000"
baclogvar = ""

REM ###### Additional services variables ######
termvar = ""
wwwvar = ""
wwwlogvar = ""
sqlvar = ""
exchangevar = ""
sapvar = ""


REM #################################################################################################
REM ###                                                                                           ###
REM ###                                         MAIN                                              ###
REM ###                                                                                           ###
REM #################################################################################################
dim temp, reply, control, check
on error resume next

REM ###### Do pre-config tasks ######
if argument("scriptbug") <> 0 then debug = 1
if argument("noscriptbug") <> 0 then debug = 0
control = config_preconfig


REM ###### Print header ######
if control <> 1 then screenout "          _________________________________________________"
if control <> 1 then screenout "         |                                                 |"
if control <> 1 then screenout "         |                                                 |"
if control <> 1 then screenout "         | Windows 2000 Custom Configuration/Update Script |"
if control <> 1 then screenout "         |             " & scriptnamevar & " (Version " & scriptversionvar & ")             |"  
if control <> 1 then screenout "         |                                                 |"
if control <> 1 then screenout "         |            (Written for IPAK " & scriptipakvar & ")            |"
if control <> 1 then screenout "         |_________________________________________________|"
if control <> 1 then screenout "         \\" & Computername & " - " & userdomain & "\" & username
if argument("head") then control = 1


REM ###### Check for Question arguments ######
if control <> 1 then if argument("-?") <> 0 then control = syntax
if control <> 1 then if argument("/?") <> 0 then control = syntax

REM ###### Script paths and variables ######
if control <> 1 then screenout ""
if control <> 1 then screenout ""
if control <> 1 then screenout "SCRIPT PATHS AND VARIABLES"
if control <> 1 then control = config_scriptpath
if argument("paths") then control=1

REM ###### Script config and authen ######
if control <> 1 then screenout ""
if control <> 1 then screenout "SCRIPT AUTHENTICATION AND CONFIGURATION"
if control <> 1 then control = config_timestart
if control <> 1 then control = config_authen
if argument("auth") then genevent "I", "3", "An undocumented script debugging command was used to only run a portion of the script!" : control=1
if control <> 1 then control = config_getinfo
if control <> 1 then control = config_getswitches
if argument("config") then genevent "I", "3", "An undocumented script debugging command was used to only run a portion of the script!" : control=1
if control <> 1 then control = config_setlocvars
if control <> 1 and argument("bug") then bug : control=1
if argument("locs") then genevent "I", "3", "An undocumented script debugging command was used to only run a portion of the script!" : control=1

REM ###### Server Config Pre-check ######
if control <> 1 then screenout ""
if control <> 1 then screenout "SERVER REBOOT PRE-CHECKS (5)"
if control <> 1 then check = check + check_delldriver
if control <> 1 then check = check + hardware_perc2fast("true")
if control <> 1 then check = check + hardware_managednode("true")
if control <> 1 then check = check + update_sp("true")
if control <> 1 then check = check + check_sysbios
if check > 0 then
	control = 1
	screenout ""
	screenout ""
	screenout "************************************************************"
	screenout "Please perform or correct the above tasks or issues!"
	scrennout "Make sure you do the tasks in the above order!"
	screenout "When every thing is completed reboot the server!"
	screenout "When the server comes back up just re-run the update script."
	screenout "************************************************************"
end if
if argument("check") then genevent "I", "3", "An undocumented script debugging command was used to only run a portion of the script" : control=1

REM ###### Server information ######
if control <> 1 then screenout ""
if control <> 1 then screenout "ADMINISTRATION"
if control <> 1 then control = admin_asset
if control <> 1 then control = admin_prework
if control <> 1 then control = admin_groups
if control <> 1 then control = admin_audit

REM ###### NT services ######
if control <> 1 then screenout ""
if control <> 1 then screenout "NT SERVICES"
if control <> 1 then control = services_schedule
if control <> 1 then control = services_time
if control <> 1 then control = services_snmp
if control <> 1 then control = services_msmq

REM ###### Hardware Software ######
if control <> 1 then screenout ""
if control <> 1 then screenout "HARDWARE SOFTWARE"
if control <> 1 then control = hardware_cpqnic
if control <> 1 then control = hardware_ssd
if control <> 1 then control = hardware_cim
if control <> 1 then control = hardware_storageworksdriver
if control <> 1 then control = hardware_managednode("false")
if control <> 1 then control = hardware_perc2fast("false")

REM ###### Upgrade Software ######
if control <> 1 then screenout ""
if control <> 1 then screenout "UPDATE SOFTWARE"
if control <> 1 then getbuildcd
if control <> 1 then control = update_reccons
if control <> 1 then getupdatecd
if control <> 1 then control = update_sp("false")
if control <> 1 then control = update_sym
if control <> 1 then control = update_fix
if control <> 1 then control = update_128

REM ###### File ######
if control <> 1 then screenout ""
if control <> 1 then screenout "FILE CHANGES"
if control <> 1 then control = file_localbin
if control <> 1 then control = file_exchange
if control <> 1 then control = file_boot
if control <> 1 then control = file_delete
if control <> 1 then control = file_bitmap

REM ###### Registry ######
if control <> 1 then screenout ""
if control <> 1 then screenout "REGISTRY CHANGES"
if control <> 1 then control = registry_backup
if control <> 1 then control = registry_main
if control <> 1 then control = registry_filters
if control <> 1 then control = registry_pagefile
if control <> 1 then control = registry_path
if control <> 1 then control = registry_source
if control <> 1 then control = registry_diskperf
if control <> 1 then control = registry_site
if control <> 1 then control = registry_debug
if control <> 1 then control = registry_services

REM ###### Additional Tools ######
if control <> 1 then screenout ""
if control <> 1 then screenout "ADDITIONAL TOOLS"
if control <> 1 then control = tools_perfcol
if control <> 1 then control = tools_oic
if control <> 1 then gettoolscd
if control <> 1 then control = tools_opassist
if control <> 1 then control = tools_sentry
if control <> 1 then control = tools_netiq
if control <> 1 then control = tools_inoculan
if control <> 1 then control = tools_backupexec
if control <> 1 then getupdatecd
if control <> 1 then control = tools_other

REM ###### Additional Services ######
if control <> 1 then screenout ""
if control <> 1 then screenout "ADDITIONAL SERVICES"
if control <> 1 then control = services_www

REM ###### Script Completion ######
if control <> 1 then screenout ""
if control <> 1 then screenout "SCRIPT COMPLETION"
temp = wshshell.Run("change user /execute", 0, true)
if err.number <> 0 then err.clear
if instr(1, netdrives, scriptdrivelocvar, 1) = 0 then
	rem screenout "Removing network drive connection (" & scriptdrivelocvar & ")..."
	WshNetwork.RemoveNetworkDrive scriptdrivelocvar, TRUE, TRUE
end if
if control <> 1 then control = completion_other
if control <> 1 then control = completion_locallogging
if control <> 1 then control = completion_destlogging
if control <> 1 then control = completion_reboot
if control <> 1 and (Wshfile.fileexists(scriptlogvar & "\" & scriptnamevar & "-run.log")) then wshfile.deletefile scriptlogvar & "\" & scriptnamevar & "-run.log", TRUE
if control <> 1 and (Wshfile.fileexists(systemdrive & "\" & scriptnamevar & "-run.log")) then wshfile.movefile systemdrive & "\" & scriptnamevar & "-run.log", scriptlogvar & "\"

Wscript.DisconnectObject Wshnetwork
Wscript.DisconnectObject Wshshell
Wscript.DisconnectObject Wshfile
Set Wshnetwork=nothing
Set Wshshell=nothing
Set Wshfile=nothing





REM #################################################################################################
REM ###                                                                                           ###
REM ###                               One Time Run Functions                                      ###
REM ###                                                                                           ###
REM #################################################################################################
REM #################################################################################################
REM ###                                   Pre-Config                                              ###
REM #################################################################################################
Function config_preconfig()
	dim arg, temp
	on error resume next

	REM ###### Sets up Vbscript to always run in command window ######
	if instr(1, wscript.fullname, "cscript.exe", 1) = 0 then
		if err.number <> 0 then err.clear
		temp = wshshell.Run("cmd /c ""cscript //h:cscript //nologo //s 1>nul 2>nul""", 0, true)
		temp = MsgBox ("The script has changed the default output of Windows Scripting Host to the command prompt." & vbCrLf & "This is pop up is normal, just re-run the script!", 0, "WSH default changed to cscript.")
		config_preconfig = 1
		exit function
	else
		temp = wshshell.Run("change user /install", 0, true)
		if err.number <> 0 then err.clear
	end if

	if err.number <> 0 then logerror "End of config_preconfig Function", err.number : err.clear
	config_preconfig = 0
End Function




REM #################################################################################################
REM ###                                  Core Script Paths                                        ###
REM #################################################################################################
Function config_scriptpath()
	dim arg, text, a, drivecoll, dc, wshdrive
	on error resume next

	REM ######  Set script path variable ######
	screenout "Getting script path information..."
	scriptpathlocvar = Replace(wscript.ScriptFullName, "\" & wscript.ScriptName, "", 1, -1, 1)
	if argument("defpath") <> 0 then
		scriptpathlocvar = bypass
	end if
	if argument("path") <> 0 then
		arg = argument("path")
		scriptpathlocvar = nextargument(arg)
		if scriptpathlocvar = "" then
			screenout ""
			screenout "You must specify the Script path after the 'path' switch!"
			screenout "Example: path \\servername\gmas\gold\ipak\nt5.01"
			config_scriptpath = 1
			exit function
		end if
	end if

	REM ### Check script path source location ###
	if not (Wshfile.FolderExists(scriptpathlocvar)) then
		screenout ""
		screenout "The Script is unable to find the directory in which it was ran from!"
		screenout "  (" & scriptpathlocvar & ")"
		screenout "Make sure you are running the script as a UNC or from a net use drive letter."
		config_scriptpath = 1
		exit function
	end if

	REM ###### Set core path variables  ######
	scriptcmdlocvar = scriptpathlocvar
	scriptinilocvar = scriptpathlocvar & "\ini"
	scriptfileslocvar = scriptpathlocvar & "\bin\" & procarc

	REM ### Check ini files source location ###
	if not (Wshfile.FolderExists(scriptinilocvar)) then
		screenout ""
		screenout "Could not locate the ini directory needed for the script!"
		screenout "Make sure you are running the script as a UNC path or from a net use drive letter."
		screenout "Make sure the below location exists from where you are running the script."
		screenout "  (" & scriptinilocvar & ")"
		config_scriptpath = 1
		exit function
	end if

	REM ### Check script files location path ###
	if not (Wshfile.FolderExists(scriptfileslocvar)) then
		screenout ""
		screenout "Could not locate the executable files needed for the script!"
		screenout "Make sure you are running the script as a UNC path or from a net use drive letter."
		screenout "Make sure the below location exists from where you are running the script."
		screenout "  (" & scriptfileslocvar & ")"
		config_scriptpath = 1
		exit function
	end if

	REM ### Check script files ###
	if not (Wshfile.FileExists(scriptfileslocvar & "\reg.exe")) then screenout "Could not find Reg.exe for the script!" : config_scriptpath = 1: exit function
	if not (Wshfile.FileExists(scriptfileslocvar & "\regsecadd.exe")) then screenout "Could not find RegSecAdd.exe for the script!" : config_scriptpath = 1 : exit function
	if not (Wshfile.FileExists(scriptfileslocvar & "\auditpol.exe")) then screenout "Could not find AuditPol.exe for the script!" : config_scriptpath = 1 : exit function
	if not (Wshfile.FileExists(scriptfileslocvar & "\bmpedit.exe")) then screenout "Could not find BMPEdit.exe for the script!" : config_scriptpath = 1 : exit function
	if not (Wshfile.FileExists(scriptfileslocvar & "\ntmem.exe")) then screenout "Could not find NTmem.exe for the script!" : config_scriptpath = 1 : exit function
	if not (Wshfile.FileExists(scriptfileslocvar & "\tlist.exe")) then screenout "Could not find TList.exe for the script!" : config_scriptpath = 1 : exit function
	if not (Wshfile.FileExists(scriptfileslocvar & "\kill.exe")) then screenout "Could not find Kill.exe for the script!" : config_scriptpath = 1 : exit function
	if not (Wshfile.FileExists(scriptfileslocvar & "\reboot.exe")) then screenout "Could not find Reboot.exe for the script!" : config_scriptpath = 1 : exit function
	if not (Wshfile.FileExists(scriptfileslocvar & "\ipakevnt.exe")) then screenout "Could not find IpakEvnt.exe for the script!" : config_scriptpath = 1 : exit function
	if not (Wshfile.FileExists(scriptfileslocvar & "\assettag.exe")) then screenout "Could not find AssetTag.exe for the script!" : config_scriptpath = 1 : exit function
	if not (Wshfile.FileExists(scriptfileslocvar & "\evaltest.exe")) then screenout "Could not find EvalTest.exe for the script!" : config_scriptpath = 1 : exit function
	screenout "  Script Path and name - " & scriptpathlocvar & "\" & scriptnamevar

	REM ###### Get drives ######
	screenout "Getting drive information..."
	set drivecoll=wshfile.drives
	for each dc in drivecoll
		alldrives = alldrives & dc.driveletter & ": "
		Set wshdrive = wshfile.GetDrive(dc.driveletter)
		Select Case wshdrive.DriveType
			Case 0: 
			Case 1: 
			Case 2: harddrives = harddrives & dc.driveletter & ": "
			Case 3: netdrives = netdrives & dc.driveletter & ": "
			Case 4: cddrives = cddrives & dc.driveletter & ": "
			Case 5: 
		End Select
	next
	screenout "  All drives found on machine - "& alldrives
	screenout "  Logical drive(s) on machine - "& harddrives
	screenout "  CD-ROM drive(s) on machine - "& cddrives
	screenout "  Network drive(s) on machine - "& netdrives

	screenout "Getting script share and drive path information..."
	REM ###### Check for UNC or drive letter connection ######
	if Instr(1, scriptpathlocvar, ":", 1) = 2 then
		scriptdrivelocvar = left(scriptpathlocvar, Instr(1, scriptpathlocvar, ":", 1))
		if scriptdrivelocvar = "" then
			screenout ""
			text = "Unable to get drive letter from script location source directory!"
			screenout text
			genevent "E", "3", text
			config_scriptpath = 1
			exit function
		end if
		Set wshmapDrives = WshNetwork.EnumNetworkDrives
		for a = 0 to wshmapdrives.Count -1 step 2
			screenout "  Mapped Drive - " & wshmapdrives.Item(a) & " - " & wshmapdrives.Item(a+1)
			if not wshmapdrives.Item(a) = "" and Instr(1, scriptpathlocvar, wshmapdrives.Item(a), 1) = 1 and a < wshmapdrives.Count then
				scriptsharelocvar = wshmapdrives.Item(a+1)
			end if
		next
		if scriptsharelocvar = "" then scriptsharelocvar = scriptdrivelocvar
		if Instr(Instr(3, scriptsharelocvar, "\", 1)+1, scriptsharelocvar, "\", 1) <> 0 then 
			screenout ""
			text = "The directory structure that is used in the net use command is too deep!"
			screenout text
			screenout "Remove the existing drive connection and re-create it using ONLY the server name and share name."
			screenout "  Example: Net use * \\server\share   NOT: Net use * \\server\share\dir"
			screenout "Make sure only ONE drive letter is mapped to the source server."
			genevent "E", "3", text
			config_scriptpath = 1
			exit function
		end if
		
	else
		scriptsharelocvar = left(scriptpathlocvar, Instr(instr(3,scriptpathlocvar, "\", 1)+1, scriptpathlocvar, "\", 1)-1)
		if scriptsharelocvar = "" then
			screenout ""
			text = "Unable to get server and share from script location source directory!"
			screenout text
			genevent "E", "3", text
			config_scriptpath = 1
			exit function
		end if
		Set wshmapDrives = WshNetwork.EnumNetworkDrives
		for a = 0 to wshmapdrives.Count -1 step 2
			screenout "  Mapped Drive - " & wshmapdrives.Item(a) & " - " & wshmapdrives.Item(a+1)
			if not wshmapdrives.Item(a) = "" and wshmapdrives.Item(a+1) = scriptsharelocvar and a < wshmapdrives.Count then
				scriptdrivelocvar = wshmapdrives.Item(a)
			end if
		next
		Set wshmapDrives=nothing
		if scriptdrivelocvar = "" then
			if instr(1, alldrives, "Z:", 1) = 0 then scriptdrivelocvar = "Z:"
			if instr(1, alldrives, "Y:", 1) = 0 then scriptdrivelocvar = "Y:"
			if instr(1, alldrives, "X:", 1) = 0 then scriptdrivelocvar = "X:"
			if instr(1, alldrives, "W:", 1) = 0 then scriptdrivelocvar = "W:"
			if instr(1, alldrives, "V:", 1) = 0 then scriptdrivelocvar = "V:"
			if instr(1, alldrives, "U:", 1) = 0 then scriptdrivelocvar = "U:"
			if instr(1, alldrives, "T:", 1) = 0 then scriptdrivelocvar = "T:"
			if instr(1, alldrives, "S:", 1) = 0 then scriptdrivelocvar = "S:"
			if instr(1, alldrives, "R:", 1) = 0 then scriptdrivelocvar = "R:"
			if instr(1, alldrives, "Q:", 1) = 0 then scriptdrivelocvar = "Q:"
			if instr(1, alldrives, "P:", 1) = 0 then scriptdrivelocvar = "P:"
			if instr(1, alldrives, "O:", 1) = 0 then scriptdrivelocvar = "O:"
			if instr(1, alldrives, "N:", 1) = 0 then scriptdrivelocvar = "N:"
			if instr(1, alldrives, "M:", 1) = 0 then scriptdrivelocvar = "M:"
			if instr(1, alldrives, "L:", 1) = 0 then scriptdrivelocvar = "L:"
			if instr(1, alldrives, "K:", 1) = 0 then scriptdrivelocvar = "K:"
			if scriptdrivelocvar = "" then
				screenout ""
				text = "No drive letters are available to map to the source server!"
				screenout text
				genevent "E", "3", text
				config_scriptpath = 1
				exit function
			end if
			if debug = 1 then screenout "  Mapping Drive - " & scriptdrivelocvar & " - " & scriptsharelocvar
			if err.number <> 0 then err.clear
			WshNetwork.MapNetworkDrive scriptdrivelocvar, scriptsharelocvar
			if err.number <> 0 then
				err.clear
				screenout ""
				text = "Could not map a drive letter to the source server share!"
				screenout text
				genevent "E", "3", text
				config_scriptpath = 1
				exit function
			end if
		end if			
	end if

	REM ###### Get script source server name ######
	if instr(3, scriptsharelocvar, "\", 1) <> 0 then
		scriptserverlocvar = mid(scriptsharelocvar, 3, instr(3, scriptsharelocvar, "\", 1) - 3)
	else
		scriptserverlocvar = ""
	end if

	REM ###### Display variables ######
	screenout "  Script Server variable - " & scriptserverlocvar
	screenout "  Script Share variable - " & scriptsharelocvar
	screenout "  Script Drive variable - " & scriptdrivelocvar

	if err.number <> 0 then logerror "End of config_scriptpath Function", err.number : err.clear
	config_scriptpath = 0
End Function





REM #################################################################################################
REM ###                                 Set Time and Start entry                                  ###
REM #################################################################################################
Function config_timestart()
	dim strcmdline, temp, text
	on error resume next

	strcmdLine = "cmd /c ""net time \\"& scriptserverlocvar & " /set /y"""
	temp = wshshell.Run(strcmdline, 0, true)
	begdate=date
	begtime=time
	text = scriptnamevar & " for IPAK " & scriptipakvar & " started on " & begdate & " at " & begtime & "."
	screenout text
	genevent "I", "1", text

	if err.number <> 0 then logerror "End of config_timestart Function", err.number : err.clear
	config_timestart = 0
End Function





REM #################################################################################################
REM ###                                     Authentication                                        ###
REM #################################################################################################
Function config_authen()
	dim strcmdline, temp, text, a, wshtempfile, alltext, suite, upgrade
	on error resume next

	REM ### Create temp directory ###
	if not (Wshfile.FolderExists(systemdrive & "\temp")) then Wshfile.CreateFolder(systemdrive & "\temp")
	if not (Wshfile.FolderExists(scripttempvar)) then Wshfile.CreateFolder(scripttempvar)

	REM ### check NT version ###
	srvvervar = WshShell.Regread("HKLM\Software\microsoft\windows nt\currentversion\currentversion")
	if err.number <> 0 then err.clear
	if srvvervar = scriptosvervar then
		screenout "Authentication for Windows Version " & srvvervar & " OK."
	else
		screenout ""
		text = "This is the wrong script for this version of Windows!"
		screenout text
		screenout "Please run a script that is designed to run on Windows version " & srvversion
		genevent "E", "3", text
		config_authen = 1
		exit function
	end if

	REM ### Check build number ###
	srvbuildvar = WshShell.RegRead("HKLM\Software\microsoft\windows nt\currentversion\currentbuildnumber")
	if err.number <> 0 then err.clear
	srvcsdvar = WshShell.Regread("HKLM\Software\microsoft\windows nt\currentversion\csdversion")
	if err.number <> 0 then err.clear
	if cint(srvbuildvar) = scriptbuildvar then
		screenout "Authentication for build " & srvbuildvar & " OK."
	else
		screenout ""
		text = "This script does not support running on this Build of Windows 2000!"
		screenout text
		screenout "Since most of the software now being installed on Windows 2000 is dependent upon 2195"
		screenout "older builds can no longer be supported."
		screenout "Please upgrade the server to 2195 RTM."
		genevent "E", "3", text
		config_authen = 1
		exit Function
	end if

	REM ###### Get server Suite type ######
	suite =  WshShell.RegRead("HKLM\system\currentcontrolset\control\productoptions\productsuite")
	if err.number <> 0 then err.clear
	for a = 0 to 5
		if isempty(suite(a)) = True then Exit for
		if suite(a) = "Enterprise" then srvsuitevar = "AS"
		if suite(a) = "DataCenter" then srvsuitevar = "DTC"
	Next
	if srvsuitevar = "AS" then
		screenout "Authentication for " & srvsuitevar & " product suite OK."
	elseif srvsuitevar = "DTC" then
		screenout "Authentication for " & srvsuitevar & " product suite OK."
		spvar = "off"
	else
		screenout ""
		text = "This script does not support the Professional or Server product suites!"
		screenout text
		screenout "Please rebuild the server to the Advanced Server or DataCenter suite."
		screenout "Upgrades to Advanced Server or DataCenter are not supported."
		genevent "E", "3", text
		config_authen = 1
		exit Function
	end if

	REM ###### Check architecture ######
	if instr(1, scriptarcvar, procarc, 1) <> 0 then
		screenout "Authentication for " & procarc & " Processor Architecture is OK."
		srvarcvar = lcase(procarc)
		if srvarcvar = "x86" then srvarcvar = "i386"
	else
		screenout ""
		text = "This script does not support this architecture of Windows 2000!"
		screenout text
		screenout "You have to run it on an x86 machine or a project needs started to support this type of architecture."
		genevent "E", "3", text
		config_authen = 1
		exit function
	end if	

	REM ###### Check for Full version ######
	strcmdLine = "cmd /c """& scriptfileslocvar & "\evaltest -s" & computername & " -v >" & scripttempvar & "\evaltemp.txt"""
	temp = wshshell.Run(strcmdline, 0, true)
	if (Wshfile.fileexists(scripttempvar & "\evaltemp.txt")) then 
		Set wshtempfile = wshfile.OpenTextFile(scripttempvar & "\evaltemp.txt", 1)
		alltext = wshtempfile.readall
		wshtempfile.Close
		wscript.DisconnectObject wshtempfile
		Set wshtempfile=nothing
		if alltext = "" then
			screenout ""
			text = "Unable to create a text file in the temporary directory for the script!"
			screenout text
			screenout "Make sure that " & scripttempvar & " exists and is writable."
			screenout "Make sure that evaltest.exe is available and working properly."
			genevent "E", "3", text
			config_authen = 1
			exit function
		elseif instr(1, alltext, "Evaluation expires", 1) and srvsuitevar = "AS" then
			text = "This server is currently running on the evaluation copy of Windows 2000!"
			screenout text
			screenout "The server will need to be upgraded before the script will continue."
			screenout "Please upgrade the server to 2195 RTM."
			screenout "Thank you!"
			genevent "E", "3", text
			config_authen = 1
			exit function
		elseif instr(1, alltext, "Evaluation expires", 1) and srvsuitevar = "DTC" then
			screenout "Authentication for evaluation version is acceptable for " & srvsuitevar & "."
		else
			screenout "Authentication for RTM " & srvsuitevar & " OK."
		end if
	else
		screenout ""
		text = "Unable to create a text file in the temporary directory for the script!"
		screenout text
		screenout "Make sure that " & scripttempvar & " exists and is writable."
		screenout "Make sure that evaltest.exe is available and working properly."
		genevent "E", "3", text
		config_authen = 1
		exit function
	end if

	REM ###### Check for admin access ######
	strcmdline = "cmd /c ""net localgroup administrators bogus\account /del 2>" & scripttempvar & "\admintemp.txt"""	
	temp = wshshell.Run(strcmdline, 0, true)
	if (Wshfile.fileexists(scripttempvar & "\admintemp.txt")) then 
		Set wshtempfile = wshfile.OpenTextFile(scripttempvar & "\admintemp.txt", 1)
		alltext = wshtempfile.readall
		wshtempfile.Close
		wscript.DisconnectObject wshtempfile
		Set wshtempfile=nothing
		if instr(1, alltext, "Access is Denied", 1) then
			screenout ""
			text = "This script cannot run without the user having administrative access to the server!"
			screenout text
			screenout "Please log off and log back on using an account with administrative access."
			genevent "E", "3", text
			config_authen = 1
			exit function
		else
			screenout "Authentication for Administrative access is OK."
		end if
	else
		screenout ""
		text = "Unable to create a text file in the temporary directory for the script!"
		screenout text
		screenout "Make sure that " & scripttempvar & " exists and is writable."
		screenout "Make sure that net.exe is available and working properly (net localgroup)."
		genevent "E", "3", text
		config_authen = 1
		exit function
	end if

	REM ###### Check for TS Session ######
	strcmdline = "cmd /c ""qwinsta >" & scripttempvar & "\tssesstemp.txt"""	
	temp = wshshell.Run(strcmdline, 0, true)
	if (Wshfile.fileexists(scripttempvar & "\tssesstemp.txt")) then 
		Set wshtempfile = wshfile.OpenTextFile(scripttempvar & "\tssesstemp.txt", 1)
		alltext = wshtempfile.readall
		wshtempfile.Close
		wscript.DisconnectObject wshtempfile
		Set wshtempfile=nothing
		if instr(1, alltext, ">rdp", 1) then
			screenout "Authentication for Terminal Service session is OK."
			scripttsvar = "yes"
		else
			screenout "Authentication for Terminal Service session is OK."
		end if
	else
		screenout ""
		text = "Unable to create a text file in the temporary directory for the script!"
		screenout text
		screenout "Make sure that " & scripttempvar & " exists and is writable."
		screenout "Make sure that qwinsta.exe is available and working properly (qwinsta)."
		genevent "E", "3", text
		config_authen = 1
		exit function
	end if

	REM ###### Check Drive free space  ######
	if checkfreespace(150) = 0 then
		screenout "Authentication for 150 MB minimum boot drive space (" & systemdrive & ") is OK."
	else
		screenout ""
		text = "There is not enough drive space on the boot drive (" & systemdrive & ") to run the update script!"
		screenout text
		screenout "Please free up a minimum of 150 MB for the script to run."
		genevent "E", "3", text
		config_authen = 1
		exit function
	end if

	if err.number <> 0 then logerror "End of config_authen Function", err.number : err.clear
	config_authen = 0
End Function



REM #################################################################################################
REM ###                                Get config information                                     ###
REM #################################################################################################
Function config_getinfo()
	dim temp, strcmdline, text, a, line, pos, pos2, pos3, size1, size2, description
	dim wshbootdrive, wshtempfile, srvrole, srvenc, alltext, terminst, termchk, sapchk
	dim system, systemset, computerob, object, objLocator, objService, objEnumerator, objInstance
	dim oemname, oemmodel, oemtype
	dim santype, securepath, hubaddress, validaddress
	on error resume next

	REM ### Get server role ###
	srvrole = WshShell.RegRead("HKLM\system\currentcontrolset\control\productoptions\producttype")
	if err.number <> 0 then err.clear
	if srvrole = "ServerNT" then
		srvrolevar = "Server"
	elseif srvrole = "LanmanNT" then
		srvrolevar = "Domain Controller"
		symvar = "full"
	else
		srvrolevar = "Unknown"
	end if
	screenout "  Detected " & srvrolevar & " role."

	REM ###### Get encryption type ######
	srvenc =  WshShell.RegRead("HKLM\software\microsoft\windows nt\currentversion\hotfix\128bit\file 1\new file")
	for a = 0 to 5
		if isempty(srvenc) = True then srvencvar = "40" : encvar = "off"
		if srvenc = "Encpack" then srvencvar = "128" : encvar = "128"
	Next
	if argument("128bit") <> 0 then encvar = "128"
	screenout "  Detected " & srvencvar & " Bit Encryption."

	REM ###### Get Domain name ######
	Set SystemSet = GetObject("winmgmts:").InstancesOf ("Win32_ComputerSystem")
	for each System in SystemSet
		srvdomainvar = System.Domain
	next
	Set System=nothing
	Wscript.DisconnectObject SystemSet
	Set SystemSet=nothing
	screenout "  Detected " & srvdomainvar & " Domain." 	

	REM ###### Get domain type ######
	if (Wshfile.fileexists(scriptinilocvar & "\muddomainlistw2k.ini")) then
		Set wshtempfile = wshfile.OpenTextFile(scriptinilocvar & "\muddomainlistw2k.ini", 1)
		alltext = wshtempfile.readall
		wshtempfile.Close
		wscript.DisconnectObject wshtempfile
		Set wshtempfile=nothing
		if Instr(1, alltext, srvdomainvar, 1) <> 0 then
			srvdomtypevar = "MUD"
		else
			srvdomtypevar = "RESOURCE"
		end if
	else
		screenout ""
		text = "The script was unable to find the MudDomainListW2K.ini file!"
		screenout text
		screenout "Make sure that " & scriptinilocvar & " exists and contains the necessary INI file."
		genevent "E", "3", text
		config_getinfo = 1
		exit function
	end if
	screenout "  Detected " & srvdomtypevar & " Domain." 	


	REM ###### Get hardware type ######
	Set objLocator = CreateObject("WbemScripting.SWbemLocator")
	Set objService = objLocator.ConnectServer ("", "root\cimv2", "", "")
	ObjService.Security_.impersonationlevel = 3
    	Set objEnumerator = objService.ExecQuery("Select vendor, version From Win32_ComputerSystemProduct",,0)
  	For Each objInstance in objEnumerator
 		oemname = objInstance.properties_("vendor")
 		oemmodel = trim(objInstance.properties_("version"))
 		oemtype = trim(objInstance.properties_("name"))
	Next
	Wscript.DisconnectObject objEnumerator
	set objEnumerator = nothing
	Wscript.DisconnectObject objService
	set objService = nothing
	Wscript.DisconnectObject objLocator
	set objLocator = nothing
	if Instr(1, oemname, "COMPAQ", 1) <> 0 then
		if (Wshfile.FileExists(systemroot & "\system32\drivers\cpqarray.sys")) then srvhardwarevar = "COMPAQ"
		if (Wshfile.FileExists(systemroot & "\system32\drivers\cpqarry2.sys")) then srvhardwarevar = "COMPAQ"
		if (Wshfile.FileExists(systemroot & "\system32\drivers\cpqcissm.SYS")) then srvhardwarevar = "COMPAQ"
		if (Wshfile.FileExists(systemroot & "\system32\drivers\perc2.sys")) then srvhardwarevar = "OTHER"
		if (Wshfile.FileExists(systemroot & "\system32\drivers\afascsi.sys")) then srvhardwarevar = "OTHER"
	elseif Instr(1, oemname, "Dell", 1) <> 0 then
		if (Wshfile.FileExists(systemroot & "\system32\drivers\cpqarray.sys")) then srvhardwarevar = "OTHER"
		if (Wshfile.FileExists(systemroot & "\system32\drivers\cpqarry2.sys")) then srvhardwarevar = "OTHER"
		if (Wshfile.FileExists(systemroot & "\system32\drivers\cpqcissm.SYS")) then srvhardwarevar = "OTHER"
		if (Wshfile.FileExists(systemroot & "\system32\drivers\perc2.sys")) then srvhardwarevar = "DELL"
		if (Wshfile.FileExists(systemroot & "\system32\drivers\afascsi.sys")) then srvhardwarevar = "DELL"
	elseif oemname = "" then
		if (Wshfile.FileExists(systemroot & "\system32\drivers\cpqarray.sys")) then srvhardwarevar = "COMPAQ"
		if (Wshfile.FileExists(systemroot & "\system32\drivers\cpqarry2.sys")) then srvhardwarevar = "COMPAQ"
		if (Wshfile.FileExists(systemroot & "\system32\drivers\cpqcissm.SYS")) then srvhardwarevar = "COMPAQ"
		if (Wshfile.FileExists(systemroot & "\system32\drivers\perc2.sys")) then srvhardwarevar = "DELL"
		if (Wshfile.FileExists(systemroot & "\system32\drivers\afascsi.sys")) then srvhardwarevar = "DELL"
	else
		srvhardwarevar = "OTHER"
	end if
	if not oemmodel = "" then
		srvhardtypevar = oemmodel
	elseif oemmodel = "" and instr(1, oemtype, "ProLiant ", 1) then
		srvhardtypevar = right(oemtype, len(oemtype) - 9)
	elseif oemmodel = "" and instr(1, oemtype, "PowerEdge ", 1) then
		srvhardtypevar = mid(oemtype, 11, 4)
	else
		srvhardtypevar = "UNKNOWN"
	end if
	screenout "  Detected " & srvhardwarevar & " hardware."
	screenout "  Detected " & srvhardtypevar & " server model."


	REM ###### Get storage works information ######
	if (argument("strtest") <> 0 or (Wshfile.FileExists(systemroot & "\system32\drivers\lp6nds35.sys")) or (Wshfile.FileExists(systemroot & "\system32\drivers\cpqkgpsa.sys"))) and argument("/nostrwrk") = 0 then 
		description = "Is this server a 'hub' or a 'switch'?" & vbCrLf & vbCrLf & "(Enter 'cancel' to exit the script.)" & vbCrLf & "(You can use the first letter of the word.)"
		santype = inputbox(description, scriptnamevar & " - Question!")
		description = "Is this server running (or going to be running) SecurePath software?"
		securepath = msgbox(description, 4, scriptnamevar & " - Question!")
		rem screenout "  (Secure Path):" & securepath
		if santype = "h" or santype = "hub" then
			validaddress = "0x01, 0x02, 0x04, 0x08, 0x0F, 0x10, 0x17, 0x18, 0x1B, 0x1D, 0x1E, 0x1F, 0x23, 0x25, 0x26, 0x27,"
			validaddress = validaddress & vbCrLf & "0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x39, 0x3A, 0x3C, 0x43,"
			validaddress = validaddress & vbCrLf & "0x45, 0x46, 0x47, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x59,"
			validaddress = validaddress & vbCrLf & "0x5A, 0x5C, 0x63, 0x65, 0x66, 0x67, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x71, 0x72, 0x73, 0x74,"
			validaddress = validaddress & vbCrLf & "0x75, 0x76, 0x79, 0x7A, 0x7C, 0x80, 0x81, 0x82, 0x84, 0x88, 0x8F, 0x90, 0x97, 0x98, 0x9B, 0x9D,"
			validaddress = validaddress & vbCrLf & "0x9E, 0x9F, 0xA3, 0xA5, 0xA6, 0xA7, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xB1, 0xB2, 0xB3, 0xB4,"
			validaddress = validaddress & vbCrLf & "0xB5, 0xB6, 0xB9, 0xBA, 0xBC, 0xC3, 0xC5, 0xC6, 0xC7, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE,"
			validaddress = validaddress & vbCrLf & "0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD9, 0xDA, 0xDC, 0xE0, 0xE1, 0xE2, 0xE4, 0xE8, 0xEF."
			description = "Please enter the Hub's ALPA address..." & vbCrLf & vbCrLf & "Default address should be: 0x01" & vbCrLf & "You must use a valid ALPA address."
			hubaddress = inputbox(description, scriptnamevar & " - ALPA Address!", "0x01")
			if hubaddress = "" or instr(1, validaddress, hubaddress, 1) = 0 then
				screenout ""
				text = "An invalid entry was entered in the input box for the ALPA address!"
				screenout text
				screenout "The ALPA address should be a hexadecimal number of this form '0x01'."
				screenout "If you are not sure of the address of this machine, contact the server owner or a "
				screenout "SAN administrator. Do NOT attempt to update the server unless you are sure of the address!"
				screenout "Valid ALPA addresses are:"
				screenout validaddress
				genevent "E", "3", text
				config_getinfo = 1
				exit function
			end if
			if securepath = 6 then
				srvstrwrksvar = "HUB-YES-" & hubaddress
			elseif securepath = 7 then
				srvstrwrksvar = "HUB-NO-" & hubaddress
			end if
		elseif (santype = "s" or santype = "switch") and securepath = 6 then
			srvstrwrksvar = "SWITCH-YES"
		elseif (santype = "s" or santype = "switch") and securepath = 7 then
			srvstrwrksvar = "SWITCH-NO"
		elseif santype = "c" or santype = "cancel" then
			screenout ""
			text = "The script has been cancelled by the user from SAN type information!"
			screenout text
			screenout "If you are not sure of the configuration of this machine, contact the server owner or a "
			screenout "SAN administrator. Do NOT attempt to update the server unless you are sure of the configuration!"
			genevent "I", "3", text
			config_getinfo = 1
			exit function
		else
			screenout ""
			text = "An invalid entry was entered in the input box for the SAN type!"
			screenout text
			screenout "When inputting SAN type information use 'switch' ('s') or 'hub' ('h')."
			screenout "Always use lower case letters."
			genevent "E", "3", text
			config_getinfo = 1
			exit function
		end if
	elseif argument("/nostrwrk") <> 0 then
		srvstrwrksvar = "DISABLED"
	else
		srvstrwrksvar = "ABSENT"
	end if
	screenout "  Detected " & srvstrwrksvar & " Storage Works."

	REM ###### Get File System ######
	Set wshbootdrive = wshfile.GetDrive(systemdrive)
	srvbootvar = wshbootdrive.FileSystem
	Wscript.DisconnectObject Wshbootdrive
	Set Wshbootdrive=nothing
	screenout "  Detected " & srvbootvar & " boot partition."

	REM ###### Get Current memory size ######
	strCmdLine = "cmd /c """& scriptfileslocvar & "\ntmem >" & scripttempvar & "\pagefile1temp.txt"""
	temp = wshshell.Run(strcmdline, 0, true)
	if err.number <> 0 then err.clear
	if (Wshfile.fileexists(scripttempvar & "\pagefile1temp.txt")) then 
		Set wshtempfile = wshfile.OpenTextFile(scripttempvar & "\pagefile1temp.txt", 1)
		if err.number <> 0 then err.clear
		Do While wshtempfile.AtEndOfStream <> true
			line = wshtempFile.ReadLine
			if instr(1, line, "Total Physical Memory", 1) then
				pos = instr(1, line, ":", 1)
				pos2 = instr(pos+2, line, " ", 1)
				size1 = cint(mid(line, pos+2, pos2-(pos+2)))
				size2 = cint(size1\32) + 1
				srvmemvar = size2 * 32
			end if
		Loop
		wshtempfile.Close
		wscript.DisconnectObject wshtempfile
		Set wshtempfile=nothing
	else
		screenout ""
		text = "Unable to create a text file in the temporary directory for the script!"
		screenout text
		screenout "Make sure that " & scripttempvar & " exists and is writable."
		screenout "Make sure that ntmem.exe in " & scriptfileslocvar & " is working properly."
		genevent "E", "3", text
		config_getinfo = 1
		exit function
	end if
	screenout "  Detected " & srvmemvar & " MB of memory."
	

	REM ###### Get Network factor ######
	if not scriptserverlocvar = "" then
		strCmdLine = "cmd /c ""ping "& scriptserverlocvar & " -w 3000 -n 1 >" & scripttempvar & "\pingtemp.txt"""
		temp = wshshell.Run(strcmdline, 0, true)
		if err.number <> 0 then err.clear
		if (Wshfile.fileexists(scripttempvar & "\pingtemp.txt")) then 
			Set wshtempfile = wshfile.OpenTextFile(scripttempvar & "\pingtemp.txt", 1)
			if err.number <> 0 then err.clear
			Do While wshtempfile.AtEndOfStream <> true
				line = wshtempFile.ReadLine
				if instr(1, line, "time=", 1) then
					pos = instr(1, line, "time=", 1)
					pos2 = instr(pos, line, "ms ", 1)
					rem screenout mid(line, pos + 5, pos2 - (pos + 5))
					netfactor = round(cint(mid(line, pos + 5, pos2 - (pos + 5)))/10)
					if netfactor <= 0 then netfactor = 1
					if netfactor >200 then netfactor = 200
				end if
			Loop
			wshtempfile.Close
			wscript.DisconnectObject wshtempfile
			Set wshtempfile=nothing
		else
			screenout ""
			text = "Unable to create a text file in the temporary directory for the script!"
			screenout text
			screenout "Make sure that " & scripttempvar & " exists and is writable."
			screenout "Make sure that ntmem.exe in " & scriptfileslocvar & " is working properly."
			genevent "E", "3", text
			config_getinfo = 1
			exit function
		end if
	end if
	screenout "  Detected network factor to be " & netfactor & "."

	REM ###### Get installed and extra services ######
	if (Wshfile.fileexists(scriptinilocvar & "\coreservicesw2k.ini")) then 
		Set wshtempfile = wshfile.OpenTextFile(scriptinilocvar & "\coreservicesw2k.ini", 1)
		alltext = wshtempFile.Readall
		wshtempfile.Close
		wscript.DisconnectObject wshtempfile
		Set wshtempfile=nothing
	else
		screenout ""
		text = "The script was unable to find the CoreServicesW2K.ini file!"
		screenout text
		screenout "Make sure that " & scriptinilocvar & " exists and contains the necessary INI file."
		genevent "E", "3", text
		config_getinfo = 1
		exit function
	end if
	allservices = ""
	extraservices = ""
	Set computerob = GetObject("WinNT://" & computername & ",computer" )
	computerob.filter = Array("Service")
	if err.number <> 0 then logerror "Test!", err.number : err.clear
	for each object in computerob
		rem screenout object.name & " (" & object.class & ")"
		if object.class = "Service" then
			allservices = allservices & object.Name & vbCrLf
			if Instr(1, alltext, object.name, 1) = 0 then
				extraservices = extraservices & object.Name & vbCrLf
			end if
		end if
	next
	if not extraservices = "" then screenout "  Detected extra services installed."

	REM ###### Get special services ######
	Terminst = WshShell.RegRead("HKLM\system\currentcontrolset\services\termservice\Start")
	Termchk = WshShell.RegRead("HKLM\system\currentcontrolset\control\Terminal Server\TSAppCompat")
	if err.number <> 0 then logerror "Reading UseLicenseServer Registry Key", err.number : err.clear
	if terminst = "2" and termchk = "0" then 
		screenout "  Detected Terminal Services service (RA)."
		termvar = "TermRa"
	elseif terminst = "2" and termchk = "1" then
		screenout "  Detected Terminal Services service (APP)."
		termvar = "TermApp"
	end if
	if Instr(1, allservices, "W3SVC", 1) <> 0 then
		screenout "  Detected WWW service."
		wwwvar = "Running"
	end if
	if Instr(1, allservices, "SQLServer", 1) <> 0 then
		screenout "  Detected SQL service."
		sqlvar = "Running"
	end if
	if Instr(1, allservices, "MSExchange", 1) <> 0 then
		screenout "  Detected Exchange service."
		exchangevar = "Running"
	end if
	sapchk = WshShell.RegRead("HKLM\software\microsoft\windows nt\currentversion\ServerType")
	if err.number <> 0 then err.clear
	if sapchk = "SAP" then 
		screenout "  Detected SAP service."
		sapvar = "Running"
	end if

	if err.number <> 0 then logerror "End of config_getinfo Function", err.number : err.clear
	config_getinfo = 0
End Function



REM #################################################################################################
REM ###                                Get switch information                                     ###
REM #################################################################################################
Function config_getswitches()
	dim arg, text, a
	on error resume next

	REM ###### Get text for all arguments ######
	argtext = wscript.ScriptFullName & " "
	for a = 0 to wscript.arguments.count - 1
		argtext = argtext & wscript.arguments(a) & " "
		if instr(1, wscript.arguments(a), "-", 1) <> 0 then
			scriptconswivar = wscript.arguments(a)
		elseif instr(1, okargtext, wscript.arguments(a), 1) = 0 then
			screenout ""
			text = "The switch '" & wscript.arguments(a) & "' is not a supported optional switch!"
			screenout text
			screenout "Please check the list of available switches by running the script with a '/?'."
			genevent "E", "3", text
			config_getswitches = 1
			exit function
		end if
		if wscript.arguments(a) = "path" or wscript.arguments(a) = "build" or wscript.arguments(a) = "bug" or wscript.arguments(a) = "sp" or wscript.arguments(a) = "/slownet" then a=a+1
	next

	REM ###### Check for switches and set variables ######
	if scriptconswivar = "" then 
		screenout ""
		text = "The configuration switch is either missing or has been entered improperly!"
		screenout text
		screenout "The configuration switch must contain a site description and a network description seperated by a dash."
		screenout "Run the script with a /? for more information."
		genevent "E", "3", text
		config_getswitches = 1
		exit function
	else
		screenout "  Switch for script configuration is: " & scriptconswivar
	end if

	if instr(1, scriptconswivar, "-corp", 1) then
		scriptnetworkvar = "CORPORATE"
	elseif instr(1, scriptconswivar, "-int", 1) then
		scriptnetworkvar = "INTERNET"
	elseif instr(1, scriptconswivar, "-ext", 1) then
		scriptnetworkvar = "EXTRANET"
	elseif instr(1, scriptconswivar, "-pri", 1) then
		scriptnetworkvar = "PRIVATE"
	else
		screenout ""
		text = "The network portion of the configuration switch has been entered improperly!"
		screenout text
		screenout "The networking portion must contain one of the following extensions: 'int', 'corp', 'ext', 'pri'"
		screenout "Run the script with a /? for more information."
		genevent "E", "3", text
		config_getswitches = 1
		exit function
	end if

	if instr(1, scriptconswivar, "/noam", 1) then
		scriptsitevar = "North America"
	elseif instr(1, scriptconswivar, "/soam", 1) then
		scriptsitevar = "South America"
	elseif instr(1, scriptconswivar, "/euro", 1) then
		scriptsitevar = "Europe"
	elseif instr(1, scriptconswivar, "/sopa", 1) then
		scriptsitevar = "South Pacific"
	elseif instr(1, scriptconswivar, "/faea", 1) then
		scriptsitevar = "Far East"
	elseif instr(1, scriptconswivar, "/miea", 1) then
		scriptsitevar = "Middle East"
	elseif instr(1, scriptconswivar, "/afca", 1) then
		scriptsitevar = "Africa"
	elseif instr(1, scriptconswivar, "/b11", 1) then
		scriptsitevar = "Building 11 Data Center"
	elseif instr(1, scriptconswivar, "/cp", 1) then
		scriptsitevar = "Canyon Park Data Center"
	elseif instr(1, scriptconswivar, "/tuk", 1) then
		scriptsitevar = "Tukwila Data Center"
	elseif instr(1, scriptconswivar, "/sat", 1) then
		scriptsitevar = "Saturn Lab"
	elseif instr(1, scriptconswivar, "/jup", 1) then
		scriptsitevar = "Jupiter Lab"
	elseif instr(1, scriptconswivar, "/soc", 1) then
		scriptsitevar = "MSN/SOC Servers"
	elseif instr(1, scriptconswivar, "/dsk", 1) then
		scriptsitevar = "DESK"
	else
		screenout ""
		text = "The site description portion of the configuration switch has been entered improperly!"
		screenout text
		screenout "The site description portion must contain a specific or a special site description."
		screenout "Run the script with a /? for more information."
		genevent "E", "3", text
		config_getswitches = 1
		exit function
	end if
	screenout "    Network type: " & scriptnetworkvar
	screenout "    Site location: " & scriptsitevar

	if argument("/com") <> 0 and srvhardwarevar = "COMPAQ" then
		screenout ""
		text = "The script has all ready detected the server to be Compaq hardware!"
		screenout text
		screenout "The /com switch should NOT be used unless the script fails to detect Compaq hardware."
		screenout "Re-Run the script without the '/com' switch."
		genevent "E", "3", text
		config_getswitches = 1
		exit function
	elseif argument("/com") <> 0 then
		screenout "  Switch for COMPAQ Hardware."
		srvhardwarevar = "COMPAQ"
	end if
	if argument("/del") <> 0 and srvhardwarevar = "DELL" then
		screenout ""
		text = "The script has all ready detected the server to be Dell hardware!"
		screenout text
		screenout "The /del switch should NOT be used unless the script fails to detect Dell hardware."
		screenout "Re-Run the script without the '/del' switch."
		genevent "E", "3", text
		config_getswitches = 1
		exit function
	elseif argument("/del") <> 0 then
		screenout "  Switch for DELL Hardware."
		srvhardwarevar = "DELL"
	end if
	if argument("/oth") <> 0 then
		screenout "  Switch for OTHER Hardware (No Compaq or Dell Components)."
		srvhardwarevar = "OTHER"
	end if
	if argument("/nocim") <> 0 then
		screenout "  Switch for NO CIM."
		cpqcimvar = "switch"
	end if


	if argument("/fullsym") <> 0 then
		screenout "  Switch for Full Symbol set install."
		symvar = "full"
	end if
	if argument("/clrsym") <> 0 then
		screenout "  Switch for clearing Symbols."
		symvar = "clear"
	end if
	if argument("/noupd") <> 0 then
		screenout "  Switch for No Update (Service Pack, Hotfixes, and Symbols disabled)."
		recconsvar = "switch"
		spvar = "switch"
		fixvar = "switch"
		symvar = "switch"
		encvar = "switch"
	end if


	if argument("/reb") <> 0 then
		screenout "  Switch for auto reboot at the end of the script."
		scriptrebootvar = "reboot"
	end if
	if argument("/noreb") <> 0 then
		screenout "  Switch for no reboot at the end of the script."
		scriptrebootvar = "noreboot"
	end if
	if argument("/debug") <> 0 then
		screenout "  Switch for full debugger settings."
		symvar = "full"
		srvdebug = 1
	end if
	if argument("/forceup") <> 0 then
		screenout "  Switch to force update of All up-to-date components."
		forceupdate = 1
	end if
	if argument("/slownet") <> 0 then
		arg = argument("/slownet")
		netfactor = nextargument(arg)
		if isnumeric(netfactor) = false or netfactor <= 0 then
			screenout ""
			text = "The '/slownet' switch requires a number to be used after the switch!"
			screenout text
			screenout "Re-run the script and include a number from 1 to 200 after the switch."
			screenout "  Example: /slownet 2"
			genevent "E", "3", text
			config_getswitches = 1
			exit function
		elseif netfactor > 200 then
			netfactor = 200
			screenout "  Switch to change network factor to " & netfactor & " (Limit of 200)."
		else
			screenout "  Switch to change network factor to " & netfactor & "."
		end if	
	end if


	if argument("/noopa") <> 0 then
		screenout "  Switch for NO OpAssist install."
		opavar = "switch"
	end if
	if argument("/nosen") <> 0 then
		screenout "  Switch for NO Sentry install."
		senvar = "switch"
	end if
	if argument("/noniq") <> 0 then
		screenout "  Switch for NO NetIQ install."
		niqvar = "switch"
	end if
	if argument("/noinoc") <> 0 then
		screenout "  Switch for NO Inoculan install."
		inocvar = "switch"
	end if
	if argument("/nooic") <> 0 then
		screenout "  Switch for NO Object Inactivity Checker install."
		oicvar = "switch"
	end if
	if argument("/nobac") <> 0 then
		screenout "  Switch for NO Backup Accelerator install."
		bacvar = "switch"
	end if
	if argument("/notools") <> 0 then
		screenout "  Switch for NO additional service changes."
		opavar = "switch"
		senvar = "switch"
		niqvar = "switch"
		inocvar = "switch"
		oicvar = "switch"
		bacvar = "switch"
	end if

	if argument("/wwwreg") <> 0 then
		screenout "  Switch for WWW related NT registry settings."
		if wwwvar = "" then wwwvar = "Switch"
	end if
	if argument("/sqlreg") <> 0 then
		screenout "  Switch for SQL related NT registry settings."
		if sqlvar = "" then sqlvar = "Switch"
	end if
	if argument("/excreg") <> 0 then
		screenout "  Switch for Exchange related NT registry settings."
		if exchangevar = "" then exchangevar = "Switch"
	end if
	if argument("/sapreg") <> 0 then
		screenout "  Switch for SAP related NT registry settings."
		if sapvar = "" then sapvar = "Switch"
	end if
	if argument("/wwwipak") <> 0 then
		screenout "  Switch for WWW IPAK execution."
		wwwvar = "IPAK"
	end if
	if argument("loctest") <> 0 then
		screenout "  Switch for WWW IPAK execution."
		locationtestvar = 1
	end if
	if argument("nontbuilds") <> 0 then
		screenout "  Switch for no Recovery Console or NTbuilds location."
		recconsvar = "switch"
		bldvar = "switch"
	end if
	if argument("notas") <> 0 then
		screenout "  Switch for no Tools and Services debug."
		opavar = "switch"
		senvar = "switch"
		niqvar = "switch"
		inocvar = "switch"
		oicvar = "switch"
		bacvar = "switch"
		wwwvar = ""
		sqlvar = ""
		exchangevar = ""
		sapvar = ""
	end if
	if argument("noots") <> 0 then
		screenout "  Switch for no OEM, Tools, or Services debug."
		cpqcimvar = "switch"
		cpqssdvar = "switch"
		delmannvar = "switch"
		delfastvar = "switch"
		deldrvvar = "switch"
		opavar = "switch"
		senvar = "switch"
		niqvar = "switch"
		inocvar = "switch"
		oicvar = "switch"
		bacvar = "switch"
		wwwvar = ""
		sqlvar = ""
		exchangevar = ""
		sapvar = ""
	end if
	if argument("noall") <> 0 then
		screenout "  Switch for NOTHING debug."
		spvar = "switch"
		fixvar = "switch"
		symvar = "switch"
		encvar = "switch"
		cpqcimvar = "switch"
		cpqssdvar = "switch"
		delmannvar = "switch"
		delfastvar = "switch"
		deldrvvar = "switch"
		opavar = "switch"
		senvar = "switch"
		niqvar = "switch"
		inocvar = "switch"
		oicvar = "switch"
		bacvar = "switch"
		wwwvar = ""
		sqlvar = ""
		exchangevar = ""
		sapvar = ""
	end if
	if argument("build") <> 0 then
		arg = argument("build")
		srvbuildvar = nextargument(arg)
		if srvbuildvar = "" then
			screenout ""
			text = "The build number needs to be included with the 'build' switch!"
			screenout text
			screenout "Please re-run the script and include a build number with the 'build' switch."
			screenout "  Example: build 2195"
			genevent "E", "3", text
			config_getswitches = 1
			exit function
		else
			screenout "  Switch to change source build location to " & srvbuildvar & "."
		end if	
	end if

	if argument("sp") <> 0 then
		arg = argument("sp")
		spdirvar = nextargument(arg)
		if spdirvar = "" then
			screenout ""
			text = "The SP number needs to be included with the 'sp' switch!"
			screenout text
			screenout "Please re-run the script and include a build number with the 'build' switch."
			screenout "  Example: sp SP1.059"
			genevent "E", "3", text
			config_getswitches = 1
			exit function
		else
			screenout "  Switch to change source SP location to " & spdirvar & "."
		end if	
	end if

	REM ###### Check for script being ran from CD ######
	if Instr(1, cddrives, scriptdrivelocvar, 1) <> 0 then 
		text = "This script is running from CD-ROM so some features will be disabled!"
		screenout text
		screenout "  Due to lack of space on the CD, the following tools and features have been disabled:"
		screenout "    - Installing the FULL symbol set"
		screenout "    - Running IPAK IIS5.01"
		screenout "  Since the CD is used only for servers on isolated networks this should not cause any problems."
		genevent "W", "4", text
		temp = MsgBox (text, 0, scriptnamevar & " - Tools and Features will be disabled!")
		cdrunvar = "on"
		symvar = "small"
		if wwwvar = "IPAK" then wwwvar = "Running"
	end if

	REM ###### Adjust settings based on Network Factor #######
	if netfactor >= 75 and netfactor < 150 then
		if symvar = "full" then
			screenouut "  Symbol install set to 'subset' due to net factor."
			symvar = "on"
		end if
	elseif netfactor >=150 then
		if symvar = "full" then
			screenouut "  Symbol install set to 'clear' due to net factor."
			symvar = "clear"
		end if
	end if

	if err.number <> 0 then logerror "End of config_getswitches Function", err.number : err.clear
	config_getswitches = 0
End Function



REM #################################################################################################
REM ###                                Set location variables                                     ###
REM #################################################################################################
Function config_setlocvars()
	dim text, color, oemcolor, toolcolor
	on error resume next

	REM ###### Get directory name ######
	if Instr(1, scriptpathlocvar, "bronze", 1) <> 0 then 
		color = "bronze"
		oemcolor = "silver"
		toolcolor = "silver"
	elseif Instr(1, scriptpathlocvar, "silver", 1) <> 0 then
		color = "silver"
		oemcolor = "silver"
		toolcolor = "silver"
	elseif Instr(1, scriptpathlocvar, "gold", 1) <> 0 then
		color = "gold"
		oemcolor = "gold"
		toolcolor = "gold"
	elseif Instr(1, scriptpathlocvar, "rust", 1) <> 0 then
		color = "rust"
		oemcolor = "rust"
		toolcolor = "rust"
	else 
		screenout ""
		text = "Unable to find the 'Color' directory in the source path to the script!"
		screenout text
		genevent "E", "3", text
		screenout "   (Gold, Silver, Bronze, or Rust)"
		screenout "Make sure that the source servers directory structure is created properly."
		screenout "Make sure that you are running the script properly."
		config_setlocvars = 1
		exit function
	end if


	REM #####################################################################################################
	REM #####################################################################################################
	REM ######                              Set location variables                                     ######
	REM #####################################################################################################
	REM #####################################################################################################
	scriptbinlocvar = scriptpathlocvar & "\" & srvbuildvar & "\" & srvsuitevar & "\" & srvarcvar & "\localbin"
	splocvar = scriptpathlocvar & "\" & srvbuildvar & "\" & srvsuitevar & "\" & srvarcvar & "\" & spdirvar
	fixlocvar = scriptpathlocvar & "\" & srvbuildvar & "\" & srvsuitevar & "\" & srvarcvar & "\" & spdirvar & "\hftrack"
	symlocvar = scriptpathlocvar & "\" & srvbuildvar & "\" & srvsuitevar & "\" & srvarcvar & "\" & spdirvar & "\symbolsubset"
	symfulllocvar = scriptpathlocvar & "\" & srvbuildvar & "\" & srvsuitevar & "\" & srvarcvar & "\" & spdirvar & "\symbols"
	wwwsymlocvar = scriptpathlocvar & "\" & srvbuildvar & "\" & srvsuitevar & "\" & srvarcvar & "\" & spdirvar & "\iissubset"
	bldlocvar = scriptsharelocvar & "\" & color & "\ntbuilds\win2k\" & srvbuildvar & "." & spdirvar & "\"& srvsuitevar
	recconslocvar = scriptsharelocvar & "\" & color & "\ntbuilds\win2k\" & srvbuildvar & "." & spdirvar & "\"& srvsuitevar& "\" & srvarcvar & "\winnt32.exe"
	enclocvar = scriptsharelocvar & "\" & color & "_dom\ipak\" & left(scriptipakvar, 6) & "\w2kencrypt.vbs"
	wwwlocvar = scriptpathlocvar & "\..\iis5.02"

	cpqssdlocvar = scriptdrivelocvar & "\" & oemcolor & "\compaq\win2000\503a"
	cpqcimlocvar = scriptdrivelocvar & "\" & oemcolor & "\compaq\win2000\503a"
	cpqstrdrvlocvar = scriptdrivelocvar & "\" & oemcolor & "\compaq\storageworks\win2000\hsg80_v85b_x86nt\kgpsa\win2k\"
	delmannlocvar = scriptdrivelocvar & "\" & oemcolor & "\dell\win2000\management\hpov1.52\hip3.5.2"
	delfastlocvar = scriptdrivelocvar & "\" & oemcolor & "\dell\win2000\management\perc2\fast_2972"
	deldrvlocvar = scriptdrivelocvar & "\" & oemcolor & "\dell\win2000\drivers\array_cntrl\perc2\rev_2963"

	oiclocvar = scriptfileslocvar & "\oic2\oicinstall.bat"
	opalocvar = scriptdrivelocvar & "\" & toolcolor & "\tools\opassist\opinst-v4.cmd"
	senlocvar = scriptdrivelocvar & "\" & toolcolor & "\tools\sentry\install5.02.bat"
	niqlocvar = scriptdrivelocvar & "\" & toolcolor & "\tools\netiq\install.bat"
	inoclocvar = scriptdrivelocvar & "\" & toolcolor & "\inoculan\inocinst.cmd"
	baclocvar = scriptdrivelocvar & "\" & toolcolor & "\veritas\be8.0\winnt\install\eng\" & srvarcvar & "\ntaa\setupaa.cmd"

	REM ### Check for localbin source location ###
	if (Wshfile.FolderExists(scriptbinlocvar)) then
		screenout "Localbin files location variable is OK."
		if debug = 1 then screenout "  (" & scriptbinlocvar & ")"
	else
		screenout ""
		text = "Could not locate the reskit files directory for the script!"
		screenout text
		screenout "  (" & scriptbinlocvar & ")"
		genevent "E", "3", text
		config_setlocvars = 1
		exit function
	end if

	REM ###### Check for needed executables ######
	if not (Wshfile.FileExists(scriptbinlocvar & "\regback.exe")) then
		text = "Could not find Regback.exe in Localbin files location!"
		screenout text
		genevent "E", "3", text
		config_setlocvars = 1
		exit function
	elseif not (Wshfile.FileExists(scriptbinlocvar & "\logevent.exe")) then
		text =  "Could not find logevent.exe in Localbin files location!"
		screenout text
		genevent "E", "3", text
		config_setlocvars = 1
		exit function
	end if

	REM ### Check for service pack location ###
	if spvar = "off" or spvar = "switch" or spdirvar = "SP0" and locationtestvar = 0 then
	elseif (Wshfile.FolderExists(splocvar)) then
		screenout "Service Pack location variable is OK."
		if debug = 1 then screenout "  (" & splocvar & ")"
	else
		screenout ""
		text = "Could not locate the Service Pack directory for the script!"
		screenout text
		screenout "  (" & splocvar & ")"
		genevent "E", "3", text
		config_setlocvars = 1
		exit function
	end if
	
	REM ### Check for hotfix location ###
	if fixvar = "off" or fixvar = "switch" and locationtestvar = 0 then
	elseif (Wshfile.FolderExists(fixlocvar)) then
		screenout "Hotfix location variable is OK."
		if debug = 1 then screenout "  (" & fixlocvar & ")"
	else
		screenout ""
		text = "Could not locate the hotfix directory for the script!"
		screenout text
		screenout "  (" & fixlocvar & ")"
		genevent "E", "3", text
		config_setlocvars = 1
		exit function
	end if
	
	REM ### Check for symbols location ###
	if symvar = "off"  or symvar = "switch" and locationtestvar = 0 then
	elseif (Wshfile.FolderExists(symlocvar)) then
		screenout "Symbol subset location variable is OK."
		if debug = 1 then screenout "  (" & symlocvar & ")"
	else
		screenout ""
		text = "Could not locate the symbol subset directory for the script!"
		screenout text
		screenout "  (" & symlocvar & ")"
		genevent "E", "3", text
		config_setlocvars = 1
		exit function
	end if

	REM ### Check for iis symbols location ###
	if symvar = "off"  or symvar = "switch" or wwwvar = "" and locationtestvar = 0 then
	elseif (Wshfile.FolderExists(wwwsymlocvar)) then
		screenout "IIS Symbols location variable is OK."
		if debug = 1 then screenout "  (" & wwwsymlocvar & ")"
	else
		screenout ""
		text = "Could not locate the IIS symbols directory for the script!"
		screenout text
		screenout "  (" & wwwsymlocvar & ")"
		genevent "E", "3", text
		config_setlocvars = 1
		exit function
	end if

	REM ### Check for full symbols location ###
	if not symvar = "full" and locationtestvar = 0 then
	elseif (Wshfile.FolderExists(symfulllocvar)) then
		screenout "Full Symbols location variable is OK."
		if debug = 1 then screenout "  (" & symfulllocvar & ")"
	else
		screenout ""
		screenout "Could not locate the Full symbols source...switching symbol install to small symbol set."
		screenout "  (" & symfulllocvar & ")"
		symvar = srvbuildvar
	end if

	REM ### Check for build tree location ###
	if (bldvar = "off" or bldvar = "switch" or cdrunvar = "on") and locationtestvar = 0 then
	elseif (Wshfile.FolderExists(bldlocvar)) then
		screenout "Build tree location variable is OK."
		if debug = 1 then screenout "  (" & bldlocvar & ")"
	else
		screenout ""
		text = "Could not locate the Build tree directory for the script!"
		screenout text
		screenout "  (" & bldlocvar & ")"
		genevent "E", "3", text
		config_setlocvars = 1
		exit function
	end if

	REM ### Check for Recovery Console location ###
	if (recconsvar = "off" or not srvbootvar = "NTFS" or recconsvar = "switch" or cdrunvar = "on") and locationtestvar = 0 then
	elseif (Wshfile.FileExists(recconslocvar)) then
		screenout "Recovery Console location variable is OK."
		if debug = 1 then screenout "  (" & recconslocvar & ")"
	else
		screenout ""
		text = "Could not locate the Recovery Console directory for the script!"
		screenout text
		screenout "  (" & recconslocvar & ")"
		genevent "E", "3", text
		config_setlocvars = 1
		exit function
	end if

	REM ### Check for 128 Bit encryption location ###
	if encvar = "off" or symvar = "switch" and locationtestvar = 0 then
	elseif (Wshfile.FileExists(enclocvar)) then
		screenout "128 Bit encyption location variable is OK."
		if debug = 1 then screenout "  (" & enclocvar & ")"
	else
		screenout ""
		text = "Could not locate the 128 Bit encryption directory for the script!"
		screenout text
		screenout "  (" & enclocvar & ")"
		genevent "E", "3", text
		config_setlocvars = 1
		exit function
	end if
	
	REM ### Check for ssd location ###
	if (not srvhardwarevar = "COMPAQ" or cpqssdvar = "off" or cpqssdvar = "switch") and locationtestvar = 0 then
	elseif (Wshfile.FolderExists(cpqssdlocvar)) then
		screenout "SSD location variable is OK."
		if debug = 1 then screenout "  (" & cpqssdlocvar & ")"
	else
		screenout ""
		text = "Could not locate the SSD directory for the script!"
		screenout text
		screenout "  (" & cpqssdlocvar & ")"
		genevent "E", "3", text
		config_setlocvars = 1
		exit function
	end if
	
	REM ### Check for CIM location ###
	if (not srvhardwarevar = "COMPAQ" or cpqcimvar = "off" or cpqcimvar = "switch") and locationtestvar = 0 then
	elseif (Wshfile.FolderExists(cpqcimlocvar)) then
		screenout "CIM location variable is OK."
		if debug = 1 then screenout "  (" & cpqcimlocvar & ")"
	else
		screenout ""
		text = "Could not locate the CIM directory for the script!"
		screenout text
		screenout "  (" & cpqcimlocvar & ")"
		genevent "E", "3", text
		config_setlocvars = 1
		exit function
	end if
	
	REM ### Check for Storage Works Driver location ###
	if (srvstrwrksvar = "DISABLED" or srvstrwrksvar = "ABSENT") and locationtestvar = 0 then
	elseif (Wshfile.FolderExists(cpqstrdrvlocvar)) then
		screenout "Storage Works Driver location variable is OK."
		if debug = 1 then screenout "  (" & cpqstrdrvlocvar & ")"
	else
		screenout ""
		text = "Could not locate the Storage Works Driver directory for the script!"
		screenout text
		screenout "  (" & cpqstrdrvlocvar & ")"
		genevent "E", "3", text
		config_setlocvars = 1
		exit function
	end if

	REM ### Check for DMN location ###
	if (not srvhardwarevar = "DELL" or delmannvar = "off" or delmannvar = "switch") and locationtestvar = 0  then
	elseif (Wshfile.FolderExists(delmannlocvar)) then
		screenout "DMN location variable is OK."
		if debug = 1 then screenout "  (" & delmannlocvar & ")"
	else
		screenout ""
		text = "Could not locate the DMN directory for the script!"
		screenout text
		screenout "  (" & delmannlocvar & ")"
		genevent "E", "3", text
		config_setlocvars = 1
		exit function
	end if

	REM ### Check for DFAST location ###
	if (not srvhardwarevar = "DELL" or delfastvar = "off" or delfastvar = "switch") and locationtestvar = 0  then
	elseif (Wshfile.FolderExists(delfastlocvar)) then
		screenout "DFAST location variable is OK."
		if debug = 1 then screenout "  (" & delfastlocvar & ")"
	else
		screenout ""
		text = "Could not locate the DFAST directory for the script!"
		screenout text
		screenout "  (" & delfastlocvar & ")"
		genevent "E", "3", text
		config_setlocvars = 1
		exit function
	end if

	REM ### Check for Perc2 driver location ###
	if (not srvhardwarevar = "DELL" or deldrvvar = "off" or deldrvvar = "switch") and locationtestvar = 0  then
	elseif (Wshfile.FolderExists(deldrvlocvar)) then
		screenout "Perc2 driver location variable is OK."
		if debug = 1 then screenout "  (" & deldrvlocvar & ")"
	else
		screenout ""
		text = "Could not locate the Perc2 driver directory for the script!"
		screenout text
		screenout "  (" & deldrvlocvar & ")"
		genevent "E", "3", text
		config_setlocvars = 1
		exit function
	end if

	if debug = 1 then screenout "Opassist location."
	if debug = 1 then screenout "  (" & opalocvar & ")"
	if debug = 1 then screenout "Sentry location."
	if debug = 1 then screenout "  (" & senlocvar & ")"
	if debug = 1 then screenout "NetIQ location."
	if debug = 1 then screenout "  (" & niqlocvar & ")"
	if debug = 1 then screenout "Inoculan location."
	if debug = 1 then screenout "  (" & inoclocvar & ")"
	if debug = 1 then screenout "OIC location."
	if debug = 1 then screenout "  (" & oiclocvar & ")"
	if debug = 1 then screenout "Backup Accelerator location."
	if debug = 1 then screenout "  (" & baclocvar & ")"

	REM ### Check for www location ###
	if (wwwvar = "" or wwwvar = "Running") and locationtestvar = 0 then
	elseif (Wshfile.FolderExists(wwwlocvar)) then
		screenout "WWW IPAK script location variable is OK."
		if debug = 1 then screenout "  (" & wwwlocvar & ")"
	else
		screenout ""
		text = "Could not locate the WWW IPAK script directory for the script!"
		screenout text
		screenout "  (" & wwwlocvar & ")"
		genevent "E", "3", text
		config_setlocvars = 1
		exit function
	end if

	if locationtestvar = 1 then config_setlocvars = 1: exit function
	if err.number <> 0 then logerror "End of config_setlocvars Function", err.number : err.clear
	config_setlocvars = 0
End Function





REM #################################################################################################
REM ###                                     Bug Function                                          ###
REM #################################################################################################
Function bug()
	dim a, location, text
	on error resume next

	screenout ""
	screenout "SCRIPT DEBUGGER"
	if argument("hardware_cpqnic") then hardware_cpqnic
	if argument("check_sysbios") then check_sysbios
	if argument("check_delldriver") then check_delldriver
	if argument("admin_asset") then admin_asset
	if argument("admin_prework") then admin_prework
	if argument("admin_groups") then admin_groups
	if argument("admin_audit") then admin_audit
	if argument("services_schedule") then services_schedule
	if argument("services_time") then services_time
	if argument("services_snmp") then services_snmp
	if argument("services_msmq") then services_msmq
	if argument("hardware_ssd") then hardware_ssd
	if argument("hardware_cim") then hardware_cim
	if argument("hardware_storageworksdriver") then hardware_storageworksdriver
	if argument("hardware_managednode") then hardware_managednode("false")
	if argument("hardware_perc2fast") then hardware_perc2fast("false")
	if argument("update_reccons") then getbuildcd: update_reccons: getupdatecd
	if argument("update_sp") then update_sp("false")
	if argument("update_sym") then update_sym
	if argument("update_fix") then update_fix
	if argument("update_128") then update_128
	if argument("file_localbin") then file_localbin
	if argument("file_exchange") then file_exchange
	if argument("file_boot") then file_boot
	if argument("file_delete") then file_delete
	if argument("file_bitmap") then file_bitmap
	if argument("registry_main") then registry_main
	if argument("registry_filters") then registry_filters
	if argument("registry_pagefile") then registry_pagefile
	if argument("registry_path") then registry_path
	if argument("registry_source") then registry_source
	if argument("registry_backup") then registry_backup
	if argument("registry_diskperf") then registry_diskperf
	if argument("registry_site") then registry_site
	if argument("registry_debug") then registry_debug
	if argument("registry_services") then registry_services
	if argument("tools_perfcol") then tools_perfcol
	if argument("tools_opassist") then tools_opassist
	if argument("tools_sentry") then tools_sentry
	if argument("tools_netiq") then tools_netiq
	if argument("tools_inoculan") then tools_inoculan
	if argument("tools_oic") then tools_oic
	if argument("tools_backupexec") then tools_backupexec
	if argument("tools_other") then tools_other
	if argument("services_www") then services_www
	if argument("completion_other") then completion_other
	if argument("completion_locallogging") then completion_locallogging
	if argument("completion_destlogging") then completion_destlogging
	if argument("completion_reboot") then completion_reboot
	genevent "I", "3", "An undocumented script debugging command was used to only run a portion of the script"

End Function





REM #################################################################################################
REM ###                                  Check System Bios                                        ###
REM #################################################################################################
Function check_sysbios()
	dim temp, strcmdline, text, biosdate, endscript
	on error resume next

	REM ### Get firmware date ###
	screenout "System BIOS Check:"
	temp = WshShell.Regread("HKLM\hardware\description\system\systembiosdate")
	if err.number = 0 then
		biosdate = datevalue(temp)
	else
		err.clear
		biosdate = "no"
	end if
	screenout "  Current System BIOS date - " & biosdate
	cpqbiosdate = datevalue(cpqbiosdate)
	delbiosdate = datevalue(delbiosdate)

	REM ### Check for biosdate location ###
	if srvhardwarevar = "COMPAQ" and srvhardtypevar = "UNKNOWN" and datecomp(cpqbiosdate, biosdate) then
		screenout "  The Compaq System BIOS on this unknown server model may be OK."
	elseif srvhardwarevar = "COMPAQ" and (srvhardtypevar = "DL380" or srvhardtypevar = "DL360") and datecomp("6/2/2000", biosdate) then
		screenout "  The Compaq System BIOS on this " & srvhardtypevar & " is OK."
	elseif srvhardwarevar = "COMPAQ" and srvhardtypevar = "850R" and datecomp("12/9/1999", biosdate) then
		screenout "  The Compaq System BIOS on this " & srvhardtypevar & " is OK."
	elseif srvhardwarevar = "COMPAQ" and (srvhardtypevar = "5500" or srvhardtypevar = "6400R" or srvhardtypevar = "6500") and datecomp("12/8/1999", biosdate) then
		screenout "  The Compaq System BIOS on this " & srvhardtypevar & " is OK."
	elseif srvhardwarevar = "COMPAQ" and (srvhardtypevar = "1850R" or srvhardtypevar = "1600" or srvhardtypevar = "3000" or srvhardtypevar = "5500" or srvhardtypevar = "6000" or srvhardtypevar = "7000" or srvhardtypevar = "8000"or srvhardtypevar = "8500") and datecomp("12/7/1999", biosdate) then
		screenout "  The Compaq System BIOS on this " & srvhardtypevar & " is OK."
	elseif srvhardwarevar = "COMPAQ" and (srvhardtypevar = "1600" or srvhardtypevar = "2500") and datecomp("6/28/1999", biosdate) then
		screenout "  The Compaq System BIOS on this " & srvhardtypevar & " is OK."
	elseif srvhardwarevar = "COMPAQ" and (srvhardtypevar = "5000" or srvhardtypevar = "6000" or srvhardtypevar = "6500" or srvhardtypevar = "7000") and datecomp("4/30/1999", biosdate) then
		screenout "  The Compaq System BIOS on this " & srvhardtypevar & " is OK."
	elseif srvhardwarevar = "COMPAQ" and srvhardtypevar = "4500" and datecomp("8/17/1998", biosdate) then
		screenout "  The Compaq System BIOS on this " & srvhardtypevar & " is OK."
	elseif srvhardwarevar = "COMPAQ" and datecomp(cpqbiosdate, biosdate) then
		screenout "  The Compaq System BIOS on this " & srvhardtypevar & " is OK."
	elseif srvhardwarevar = "COMPAQ" then
		screenout ""
		text = "The Compaq System BIOS on this server needs to be updated before the update script can continue!"
		screenout text
		screenout "The known minimum System BIOS dates that are required for this IPAK are:"
		screenout "  Proliant DL380, DL360 - 6/2/2000"
		screenout "  Proliant 850R (P04) - 12/9/1999"
		screenout "  Proliant 5500 Xeon (P12), 6400R (E25), and 6500R Xeon (P11) - 12/8/1999"
		screenout "  Proliant 1850R (P07), 1600 (P08), 3000 (P09/E39), 5500 (E39) - 12/7/1999"
		screenout "  Proliant 6000 Xeon (P40/P43), 7000 Xeon (P40/P43), 8000 (P41), and 8500 (P42) - 12/7/1999"
		screenout "  Proliant 1600 (E34) and 2500 (E25/E39) - 6/28/1999"
		screenout "  Proliant 5000 (E16), 6000 (E20), 6500 (E25), and 7000 (E40) - 4/30/1999"
		screenout "  Proliant 4500 (E14) - 8/17/1998"
		screenout "The Rompaq's for the system bios can be found at:"
		screenout  "  " & scriptsharelocvar & "\gold\compaq\roms\system"
		screenout ""
		genevent "E", "3", text
		check_sysbios = 1
		exit function
	elseif srvhardwarevar = "DELL" and srvhardtypevar = "UNKNOWN" and datecomp(delbiosdate, biosdate) then
		screenout "  The Dell System BIOS on this unknown server model may be OK."
	elseif srvhardwarevar = "DELL" and (srvhardtypevar = "6300" or srvhardtypevar = "6350") and datecomp("10/27/99", biosdate) then
		screenout "  The Dell System BIOS on this " & srvhardtypevar & " is OK."
	elseif srvhardwarevar = "DELL" and srvhardtypevar = "2450" and datecomp("12/21/99", biosdate) then
		screenout "  The Dell System BIOS on this " & srvhardtypevar & " is OK."
	elseif srvhardwarevar = "DELL" and datecomp(delbiosdate, biosdate) then
		screenout "  The Dell System BIOS on this " & srvhardtypevar & " is OK."
	elseif srvhardwarevar = "DELL" then
		screenout ""
		text = "The Dell System BIOS on this server needs to be updated before the update script can continue!"
		screenout text
		screenout "The known minimum System BIOS dates that are required for this IPAK are:"
		screenout "   Dell Poweredge 6300 and 6350 - 10/27/99 (A11)"
		screenout "   Dell Poweredge 2450 - 12/21/99 (A02)"
		screenout "The updates for the System BIOS can be found at:"
		screenout  "  " & scriptsharelocvar & "\gold\dell\roms\system\6300\bios_A11"
		screenout ""
		genevent "E", "3", text
		check_sysbios = 1
		exit function
	else
		screenout "  The System BIOS on this platform does not need checked."
	end if

	if err.number <> 0 then logerror "End of check_sysbios Function", err.number : err.clear
	check_sysbios = 0
End Function





REM #################################################################################################
REM ###                                     Dell Perc2 Driver                                     ###
REM #################################################################################################
Function check_delldriver()
	dim temp, strcmdline, text, wrongfile, filethere, servfile
	on error resume next


	REM ### Check for driver dates ###
	screenout "Dell PERC2 Driver (2.1 - 2963):"
	if not srvhardwarevar = "DELL" then
		screenout "  The Dell Perc2 driver does not exist on this hardware platform."
		deldrvlogvar = "Different Hardware Platform."
	else
		REM ### Get perc2 driver date ###
		if (Wshfile.fileexists(deldrvchkvar)) then
			set servfile = Wshfile.getfile(deldrvchkvar)
			filethere = datevalue(left(servfile.datelastmodified, Instr(1, servfile.datelastmodified, " ", 1)-1))
			wscript.DisconnectObject servfile
			set servfile=nothing
		else
			filethere = "no"
		end if
		if (Wshfile.fileexists(systemroot & "\system32\drivers\afascsi.sys")) then filethere = "Upgrade"
		deldrvfilevar = datevalue(deldrvfilevar)

		if debug = 1 then screenout "  (Perc2 File: " & filethere & ")"

		if datecomp(deldrvfilevar, filethere) then
			screenout "  Dell Perc2 driver (" & deldrvvar & ") OK."
			deldrvlogvar = "OK"
		else
			screenout ""
			text = "The Dell Perc2 Driver needs to be updated before the update script can continue!"
			screenout text
			screenout "The Dell Perc2 Driver needs to be running version " & deldrvvar & "." 
			screenout "This requires user intervention! Please follow these steps:"
			screenout "  In 'Device Manager' of 'Computer Manager'"
			screenout "    - Open the 'SCSI and RAID Controllers' Devices"
			screenout "  On the 'Dell PERC 2 RAID Controller' device"
			screenout "    - Right click and select 'Properties'"
			screenout "  In the 'Dell PERC 2 RAID Controller Properties' window"
			screenout "    - Select the 'Driver' tab and click on the 'Update Driver' button"
			screenout "  In the 'Upgrade Device Driver Wizard' window"
			screenout "    - Press the 'Next' button"
			screenout "    - Make sure the 'Display a list of known drivers for this device"
			screenout "      so that I can choose a specific driver' radial button is checked"
			screenout "    - Press the 'Next' button"
			screenout "    - Press the 'Have Disk' button"
			screenout "  In the 'Install from Disk' window"
			screenout "    - Press the 'Browse' button"
			screenout "  In the 'Locate File' window"
			screenout "    - Open up the 'Look in' box and select the " & scriptdrivelocvar & " drive"
			screenout "    - Move into the " & deldrvlocvar & " directory"
			screenout "    - Highlight the 'oemsetup.inf' file"
			screenout "    - Press the 'Open' button"
			screenout "  In the 'Install from Disk' window"
			screenout "    - Press the 'OK' button"
			screenout "  In the 'Upgrade Device Driver Wizard' window"
			screenout "    - Highlight the 'Dell PERC 2 RAID Controller' Model and press the 'Next' button"
			screenout "    - Press the 'Next' button"
			screenout "  In the 'Digital Signature Not Found' window"
			screenout "    - Press the 'Yes' button "
			screenout " In the 'Upgrade Device Driver Wizard' window"
			screenout "    - Press the 'Finish' button"
			screenout "    - Close out of the properties window"
			screenout "  In the 'System Settings Change' window"
			screenout "    - Press the 'No' button"
			screenout "Repeat the above steps for ALL PERC2 devices!"
			screenout "Check 'Other Devices' in 'Device Manager' for any unknown Dell devices."
			screenout "  (Such as 'Dell 1x8 U2W SCSI BP SCSI Processor Device')"
			screenout "  If a device exists, follow the above procedure on that device except"
			screenout "  use the 'OEMSETUP2.inf' file. There will not be a Digital Signature pop up."
			screenout "  If the above procedure fails, use the 'Search for a suitable driver...' option."
			screenout "When the server is down, check the PERC2 Firmware and upgrade it if needed"
			screenout "  The PERC2 firmware should be running Version 2.1 Build 2939 or newer!"
			screenout "  Make sure the PERC2 driver and firmware are not mis-matched versions!"
			screenout "  It is critical that both PERC2 driver and firmware are Version 2.1!"
			screenout ""
			genevent "E", "3", text
			check_delldriver = 1
			strcmdline = "cmd /c ""compmgmt.msc /s"""	
			temp = wshshell.Run(strcmdline, 0, true)
			exit function
		end if
	end if

	if err.number <> 0 then logerror "End of check_delldriver Function", err.number : err.clear
	check_delldriver = 0
End Function




REM #################################################################################################
REM ###                                           Asset Tag                                       ###
REM #################################################################################################
Function admin_asset()
	dim temp, strcmdline, text, entriesok, count, asset, serial, location
	on error resume next

	REM ### Check Asset Tag Stuff ###
	screenout "Asset Tagger:"
	if scriptsitevar = "DESK" then
		screenout "  Asset Tag Information is not needed on a Desktop configurations."
	else
		entriesok = 0
		do
			asset = WshShell.RegRead("HKLM\system\currentcontrolset\services\snmp\parameters\rfc1156agent\syscontact")
			if err.number <> 0 then err.clear
			serial = WshShell.RegRead("HKLM\system\currentcontrolset\services\snmp\parameters\rfc1156agent\sysserialnumber")
			if err.number <> 0 then err.clear
			location = WshShell.RegRead("HKLM\system\currentcontrolset\services\snmp\parameters\rfc1156agent\syslocation")
			if err.number <> 0 then err.clear
			if count > 20 then
				screenout ""
				text = "  Entries for the Asset Tagger Utility have failed more then 20 times!"
				screenout text
				screenout "    Please check the script documentation for the appropriate entries and re-run the script."
				genevent "E", "3", text
				entriesok = 1
				admin_asset = 1
				exit function
			elseif asset = "" and serial = "" and location = "" then
				screenout "  All entries in the Asset Tagger Utility need to be filled out..."
				screenout "    Example:"
				screenout "            321561"
				screenout "            D740BPV10025"
				screenout "            11/S25-W12 (3)"
				strcmdline = scriptfileslocvar & "\assettag.exe"
				temp = wshshell.Run(strcmdline, 1, true)
			elseif asset = "" then
				screenout "  The 'Asset Tag' entry in the Asset Tagger Utility needs to be filled out..."
				screenout "    The Asset Tag number should contain the number on the Microsoft Asset sticker on the computer."
				screenout "    Examples:"
				screenout "             321561"
				screenout "             MS0011111 "
				screenout "             L321561"
				screenout "    If the server is not owned by Microsoft you can enter '000000' into the Asset Tag # field."
				strcmdline = scriptfileslocvar & "\assettag.exe"
				temp = wshshell.Run(strcmdline, 1, true)
			elseif serial = "" then
				screenout "  The 'Serial Number' entry in the Asset Tagger Utility needs to be filled out..."
				screenout "    The Serial number should contain the serial number marked on the computer."
				screenout "    Example:"
				screenout "            D740BPV10025"
				strcmdline = scriptfileslocvar & "\assettag.exe"
				temp = wshshell.Run(strcmdline, 1, true)
			elseif location = "" then
				screenout "  The 'Location' entry in the Asset Tagger Utility needs to be filled out..."
				screenout "    The Location entry should contain a building abreviation of no less then 2 characters,"
				screenout "    followed by a forward slash, followed by a rack location of no less then 4 characters."
				screenout "    Additional information should be enclosed in parenthesis (such as concentrator position)."
				screenout "    Examples:"
				screenout "             11/S25-W12 (6,1)"
				screenout "             CP-E/W01N36 (3)"
				screenout "             CPL/2162"
				screenout "    If this server is a test machine you can enter 'Test' for the Location field."
				strcmdline = scriptfileslocvar & "\assettag.exe"
				temp = wshshell.Run(strcmdline, 1, true)
			elseif not location = "Test" and Instr(1, location, "/", 1) = 0  then
				screenout "  The 'Location' entry in the Asset Tagger Utility needs to contain a forward slash seperator..."
				screenout "    The Location entry should contain a building abreviation of no less then 2 characters,"
				screenout "    followed by a forward slash, followed by a rack location of no less then 4 characters."
				screenout "    Additional information should be enclosed in parenthesis (such as concentrator position)."
				screenout "    Examples:"
				screenout "             11/S25-W12 (6,1)"
				screenout "             CP-E/W01N36 (3)"
				screenout "             CPL/2162"
				screenout "    If this server is a test machine you can enter 'Test' for the Location field."
				strcmdline = scriptfileslocvar & "\assettag.exe"
				temp = wshshell.Run(strcmdline, 1, true)
			elseif count = 0 then
				screenout "  Check Asset Tagger Utility entries for changes..."
				strcmdline = scriptfileslocvar & "\assettag.exe"
				temp = wshshell.Run(strcmdline, 1, false)
				entriesok = 1
				exit do
			else
				screenout "  Asset Tagger Utility entries are OK."
				entriesok = 1
				exit do
			end if
			count = count + 1
		loop while entriesok = 0
	end if

	if err.number <> 0 then logerror "End of admin_asset Function", err.number : err.clear
	admin_asset = 0
End Function





REM #################################################################################################
REM ###                                         Pre Work                                          ###
REM #################################################################################################
Function admin_prework()
	dim strcmdline, temp, text
	on error resume next

	REM ###### Stop File replication Services ######
	screenout "Stopping Windows 2000 File Replication Service..."
	strcmdline = "cmd /c ""net stop ntfrs"""	
	temp = wshshell.Run(strcmdline, 0, true)
	if err.number <> 0 then err.clear

	if err.number <> 0 then logerror "End of admin_prework Function", err.number : err.clear
	admin_prework = 0
End Function





REM #################################################################################################
REM ###                                        Groups                                             ###
REM #################################################################################################
Function admin_groups()
	dim strcmdline, temp, text
	on error resume next

	REM ###### Check for admin access ######
	if scriptsitevar = "DESK" then
		screenout "Administration Group manipulation not needed on DESK top configurations."
	elseif srvrolevar = "Server" then 
		screenout "Manipulating Groups for administration..."
		strcmdline = "cmd /c ""net localgroup administrators Redmond\itg-admin /add"""	
		temp = wshshell.Run(strcmdline, 0, true)
		strcmdline = "cmd /c ""net localgroup administrators Houston\itg-admin /add"""	
		temp = wshshell.Run(strcmdline, 0, true)
		strcmdline = "cmd /c ""net localgroup ""Backup Operators"" ""REDMOND\itg-backup operators"" /add"""	
		temp = wshshell.Run(strcmdline, 0, true)
		strcmdline = "cmd /c ""net localgroup ""Backup Operators"" ""HOUSTON\BUAdmin"" /add"""	
		temp = wshshell.Run(strcmdline, 0, true)
	else
		screenout "Administration Group manipulation not supported on Domain Controllers."
	end if

	if err.number <> 0 then logerror "End of admin_groups Function", err.number : err.clear
	admin_groups = 0
End Function





REM #################################################################################################
REM ###                                      Auditing                                             ###
REM #################################################################################################
Function admin_audit()
	dim strcmdline, temp, text
	on error resume next

	REM ###### Check for admin access ######
	if scriptsitevar = "DESK" then
		screenout "Administration Audit manipulation not needed on DESK top configurations."
	elseif srvrolevar = "Server" then 
		screenout "Manipulating Auditing for administration..."
		strcmdLine = "cmd /c """& scriptfileslocvar & "\auditpol.exe /logon:all /sam:all /policy:all /account:all """
		temp = wshshell.Run(strcmdline, 0, true)
	else
		screenout "Administration Audit manipulation not supported on Domain Controllers."
	end if

	if err.number <> 0 then logerror "End of admin_audit Function", err.number : err.clear
	admin_audit = 0
End Function



REM #################################################################################################
REM ###                                  Schedule service                                         ###
REM #################################################################################################
Function services_schedule()
	dim strcmdline, temp, alltext, wshtempfile, service, text
	on error resume next

	REM ###### Scheduler service ######
	strcmdline = "cmd /c ""net start > " & scripttempvar & "\servicestemp.txt"""	
	temp = wshshell.Run(strcmdline, 0, true)
	if (Wshfile.fileexists(scripttempvar & "\servicestemp.txt")) then 
		Set wshtempfile = wshfile.OpenTextFile(scripttempvar & "\servicestemp.txt", 1)
		alltext = wshtempfile.readall
		wshtempfile.Close
		wscript.DisconnectObject wshtempfile
		Set wshtempfile=nothing
		if instr(1, alltext, "Task Scheduler", 1) then
			screenout "Task Scheduler OK."
		else
			screenout "Task Scheduler service being configured and started..."
			wshshell.regwrite "HKLM\system\currentcontrolset\services\schedule\start", 2, "REG_DWORD"
			logregistryentry "Scheduler Service Automatic Start", "Corrected", "HKLM\system\currentcontrolset\services\schedule\start", "2"
			if err.number <> 0 then err.clear
			wshshell.regwrite "HKLM\system\currentcontrolset\services\schedule\objectname", "LocalSystem", "REG_SZ"
			logregistryentry "Scheduler Service Account", "Corrected", "HKLM\system\currentcontrolset\services\schedule\objectname", "LocalSystem"
			if err.number <> 0 then err.clear
			temp = wshshell.Run("cmd /c ""net start schedule""", 0, true)
		end if
	else
		screenout "Unable to open services text file!"
	end if

	if err.number <> 0 then logerror "End of services_schedule Function", err.number : err.clear
	services_schedule = 0
End Function



REM #################################################################################################
REM ###                                  Time service                                             ###
REM #################################################################################################
Function services_time()
	dim strcmdline, temp, text, pos1, pos2, line, wshtempfile, scriptinfravar, ipconfigtext, nettimetext, sntplist
	dim attext, atlist, number, hour, minute
	on error resume next

	REM ###### Find what operating system infrastructure the server is in ######
	screenout "Time service configuration..."
	strcmdline = "cmd /c ""ipconfig /all > " & scripttempvar & "\ipconfigtemp.txt"""	
	temp = wshshell.Run(strcmdline, 0, true)
	if (Wshfile.fileexists(scripttempvar & "\ipconfigtemp.txt")) then
		Set wshtempfile = wshfile.OpenTextFile(scripttempvar & "\ipconfigtemp.txt", 1)
		if err.number <> 0 then err.clear
		ipconfigtext = wshtempfile.readall
		wshtempfile.Close
		wscript.DisconnectObject wshtempfile
		Set wshtempfile=nothing

		pos1 = Instr(1, ipconfigtext, "Primary DNS Suffix", 1)
		pos2 = Instr(pos1, ipconfigtext, chr(10), 1)
		line = mid(ipconfigtext, pos1+36, pos2-pos1-37)
		if line = "redmond.corp.microsoft.com" and Instr(1, ipconfigtext, "PRXY", 1) <> 0 then
			scriptinfravar = "W2Kprxy"
			screenout "  Server is a Redmond Proxy time server (" & line & ")."
		elseif line = "corp.microsoft.com" then
			scriptinfravar = "W2Kroot"
			screenout "  Server is in a Windows 2000 infrastructure root domain (" & line & ")."
		elseif line = "microsoft.com" then
			scriptinfravar = "W2Kroot"
			screenout "  Server is in a Windows 2000 infrastructure root domain (" & line & ")."
		elseif line = "" then
			scriptinfravar = "NT"
			screenout "  Server is in an NT 4.0 infrastructure (" & line & ")."
		else
			scriptinfravar = "W2K"
			screenout "  Server is in a Windows 2000 infrastructure (" & line & ")."
		end if
	else
		screenout ""
		text = "Unable to create a text file in the temporary directory for the script!"
		screenout text
		screenout "Make sure that " & scripttempvar & " exists and is writable."
		screenout "Make sure that ipconfig.exe is available and working properly (ipconfig /all)."
		genevent "E", "3", text
		services_time = 1
		exit function
	end if

	REM ###### Find if SNTP values are set or not ######
	strcmdline = "cmd /c ""net time /querysntp > " & scripttempvar & "\timetemp.txt"""	
	temp = wshshell.Run(strcmdline, 0, true)
	if (Wshfile.fileexists(scripttempvar & "\timetemp.txt")) then 
		Set wshtempfile = wshfile.OpenTextFile(scripttempvar & "\timetemp.txt", 1)
		nettimetext = wshtempfile.readall
		wshtempfile.Close
		wscript.DisconnectObject wshtempfile
		Set wshtempfile=nothing
		if Instr(1, nettimetext, "131.107.1.10 192.5.41.40 192.43.244.18", 1) <> 0 then 
			sntplist = "internet"
			screenout "  SNTP values set to Internet Time servers (131.107.1.10 192.5.41.40 192.43.244.18)."
		elseif Instr(1, nettimetext, "itgproxy.redmond.corp.microsoft.com", 1) <> 0 then 
			sntplist = "proxy"
			screenout "  SNTP values set to proxy servers (itgproxy.redmond.corp.microsoft.com)."
		else  
			sntplist = "empty"
			screenout "  SNTP values NOT currently configured on this server. ()"
		end if
	else
		screenout ""
		text = "Unable to create a text file in the temporary directory for the script!"
		screenout text
		screenout "Make sure that " & scripttempvar & " exists and is writable."
		screenout "Make sure that net.exe is available and working properly (net time)."
		genevent "E", "3", text
		services_time = 1
		exit function
	end if


	REM ###### Find if net time at jobs exist ######
	strcmdline = "cmd /c ""at \\" & computername & " > " & scripttempvar & "\atjobstemp.txt"""	
	temp = wshshell.Run(strcmdline, 0, true)
	if (Wshfile.fileexists(scripttempvar & "\atjobstemp.txt")) then 
		Set wshtempfile = wshfile.OpenTextFile(scripttempvar & "\atjobstemp.txt", 1)
		attext = wshtempfile.readall
		wshtempfile.Close
		wscript.DisconnectObject wshtempfile
		Set wshtempfile=nothing
		if Instr(1, attext, "timesync.cmd", 1) <> 0 then 
			atlist = "full"
			screenout "  TimeSync At jobs exist. (Timesync.cmd)"
		else 
			atlist = "empty"
			screenout "  TimeSync At jobs do not exist. ()"
		end if
	else
		screenout ""
		text = "Unable to create a text file in the temporary directory for the script!"
		screenout text
		screenout "Make sure that " & scripttempvar & " exists and is writable."
		screenout "Make sure that at.exe is available and working properly (at \\servername)."
		genevent "E", "3", text
		services_time = 1
		exit function
	end if


	REM ###### Set Time service accordingly ######
	if scriptinfravar = "W2Kprxy" and not sntplist = "internet" then
		screenout "  Time service being set with NTP Internet servers list..."
		strcmdline = "cmd /c ""net time /setsntp:""131.107.1.10 192.5.41.40 192.43.244.18"""""	
		temp = wshshell.Run(strcmdline, 0, true)
	elseif scriptinfravar = "W2Kroot" and not sntplist = "proxy" then
		screenout "  Time service being set with NTP itgproxy value..."
		strcmdline = "cmd /c ""net time /setsntp:""itgproxy.redmond.corp.microsoft.com"""""	
		temp = wshshell.Run(strcmdline, 0, true)
	elseif scriptinfravar = "W2K" and not sntplist = "empty" then
		screenout "  Time service being cleared of NTP server list..."
		strcmdline = "cmd /c ""net time /setsntp:"""	
		temp = wshshell.Run(strcmdline, 0, true)
	elseif scriptinfravar = "NT" and not sntplist = "empty" then
		screenout "  Time service being cleared of NTP server list..."
		strcmdline = "cmd /c ""net time /setsntp:"""	
		temp = wshshell.Run(strcmdline, 0, true)
	else
		screenout "  Time service configured OK."
	end if


	REM ###### Set AT jobs correctly ######
	if scriptinfravar = "NT" and atlist = "empty" then
		screenout "  Adding Timesync AT jobs..."
		randomize
		hour = Int((6 - 1 + 1) * Rnd(0) + 1)
		randomize
		minute = Int((59 - 0 + 1) * Rnd(0) + 0)
		strcmdline = "cmd /c ""at \\" & computername & " " & hour &":" & minute & " /EVERY:m,t,w,th,f,s,su " & scriptbinvar & "\timesync.cmd"""	
		temp = wshshell.Run(strcmdline, 0, true)
		strcmdline = "cmd /c ""at \\" & computername & " " & hour + 6 &":" & minute & " /EVERY:m,t,w,th,f,s,su " & scriptbinvar & "\timesync.cmd"""	
		temp = wshshell.Run(strcmdline, 0, true)
		strcmdline = "cmd /c ""at \\" & computername & " " & hour + 12 &":" & minute & " /EVERY:m,t,w,th,f,s,su " & scriptbinvar & "\timesync.cmd"""	
		temp = wshshell.Run(strcmdline, 0, true)
		strcmdline = "cmd /c ""at \\" & computername & " " & hour + 18 &":" & minute & " /EVERY:m,t,w,th,f,s,su " & scriptbinvar & "\timesync.cmd"""	
		temp = wshshell.Run(strcmdline, 0, true)
	elseif not scriptinfravar = "NT" and atlist = "full" then
		screenout "  Removing AT jobs..."
		if (Wshfile.fileexists(scripttempvar & "\atjobstemp.txt")) then 
			Set wshtempfile = wshfile.OpenTextFile(scripttempvar & "\atjobstemp.txt", 1)
			Do While wshtempfile.AtEndOfStream <> true
				line = wshtempFile.ReadLine
				if Instr(1, line, "timesync", 1) then
					number = int(mid(line, 8, 2))
					screenout "    ID " & number & "..."
					strcmdline = "cmd /c ""at " & number & " /d"""	
					temp = wshshell.Run(strcmdline, 0, true)
				end if
			Loop
			wshtempfile.Close
			wscript.DisconnectObject wshtempfile
			Set wshtempfile=nothing
		else
			screenout "  Unable to open At file!"
		end if
	else
		screenout "  Timesync AT jobs OK."
	end if


	if err.number <> 0 then logerror "End of services_time Function", err.number : err.clear
	services_time = 0
End Function



REM #################################################################################################
REM ###                                      SNMP service                                         ###
REM #################################################################################################
Function services_snmp()
	dim srvinstalled, strcmdline, temp, text, wshaddonfile
	on error resume next

	REM ###### Snmp service ######
	srvinstalled = WshShell.RegRead("HKLM\system\currentcontrolset\services\snmp\imagepath")
	if err.number <> 0 then err.clear
        if instr(1, srvinstalled, "snmp.exe", 1) <> 0 then
		screenout "SNMP service OK."
	else
		screenout "SNMP service being installed..."
		if (Wshfile.FileExists(systemdrive & "\addon.inf")) then wshfile.deletefile systemdrive & "\addon.inf", TRUE
		set wshaddonfile = wshfile.createtextfile(systemdrive & "\addon.inf",1)
 		wshaddonfile.writeline("[NetOptionalComponents]")
		wshaddonfile.writeline("SNMP = 1")
		wshaddonfile.close
		wscript.DisconnectObject wshaddonfile
		set wshaddonfile=nothing
		strcmdline = "cmd /c ""sysocmgr /i:sysoc.inf /u:" & systemdrive & "\addon.inf /r"""	
		temp = wshshell.Run(strcmdline, 0, true)
		if (Wshfile.FileExists(systemdrive & "\addon.inf")) then wshfile.deletefile systemdrive & "\addon.inf", TRUE
	end if

	if err.number <> 0 then logerror "End of services_snmp Function", err.number : err.clear
	services_snmp = 0
End Function



REM #################################################################################################
REM ###                                      MSMQ service                                         ###
REM #################################################################################################
Function services_msmq()
	dim srvinstalled, strcmdline, temp, text, wshaddonfile
	on error resume next

	REM ###### MSMQ service ######
	srvinstalled = WshShell.RegRead("HKLM\system\currentcontrolset\services\msmq\imagepath")
	if err.number <> 0 then err.clear
	if srvrolevar = "Domain Controller" and srvdomtypevar = "MUD" and instr(1, srvinstalled, "mqsvc.exe", 1) <> 0 then
		screenout "MSMQ service OK."
	elseif srvrolevar = "Domain Controller" and srvdomtypevar = "MUD" then
		screenout "MSMQ service being installed..."
		if (Wshfile.FileExists(systemdrive & "\addon.inf")) then wshfile.deletefile systemdrive & "\addon.inf", TRUE
		set wshaddonfile = wshfile.createtextfile(systemdrive & "\addon.inf",1)
 		wshaddonfile.writeline("[Components]")
		wshaddonfile.writeline("msmq = on")
		wshaddonfile.close
		wscript.DisconnectObject wshaddonfile
		set wshaddonfile=nothing
		strcmdline = "cmd /c ""sysocmgr /i:sysoc.inf /u:" & systemdrive & "\addon.inf /r"""	
		temp = wshshell.Run(strcmdline, 0, true)
		if (Wshfile.FileExists(systemdrive & "\addon.inf")) then wshfile.deletefile systemdrive & "\addon.inf", TRUE
	else
		screenout "MSMQ service needed only on MUDC's."
	end if

	if err.number <> 0 then logerror "End of services_msmq Function", err.number : err.clear
	services_msmq = 0
End Function




REM #################################################################################################
REM ###                                    Check Compaq NIC                                       ###
REM #################################################################################################
Function hardware_cpqnic()
	dim text, temp, strcmdline, wshtempfile, ipconfigtext, wshinifile, nic
	on error resume next

	REM ###### Find what operating system infrastructure the server is in ######
	screenout "COMPAQ DTC NIC Check:"
	if srvsuitevar = "DTC" and srvhardwarevar = "COMPAQ" then
		strcmdline = "cmd /c ""ipconfig /all > " & scripttempvar & "\ipconfigtemp.txt"""	
		temp = wshshell.Run(strcmdline, 0, true)
		if (Wshfile.fileexists(scripttempvar & "\ipconfigtemp.txt")) then
			Set wshtempfile = wshfile.OpenTextFile(scripttempvar & "\ipconfigtemp.txt", 1)
			if err.number <> 0 then err.clear
			ipconfigtext = wshtempfile.readall
			wshtempfile.Close
			wscript.DisconnectObject wshtempfile
			Set wshtempfile=nothing
			rem screenout ipconfigtext
			if (Wshfile.fileexists(scriptinilocvar & "\DisableNicsW2K.ini")) then 
				Set wshinifile = wshfile.OpenTextFile(scriptinilocvar & "\DisableNicsW2K.ini", 1)
				Do While wshinifile.AtEndOfStream <> true
					nic = wshiniFile.ReadLine
					rem screenout nic
					if not instr(1, ipconfigtext, nic, 1) = 0 then
						screenout ""
						text = "The script detected a Compaq NIC that needs to be disabled when used with the Datacenter suite!" 
						screenout text
						text = text & " (" & nic & ")" 
						screenout "  (" & nic & ")"
						screenout "The device can be disabled using 'Device Manager' in 'Computer Manager'."
						screenout "Find the above listed device under 'Network Adapters', right click on it, and select disable."
						screenout "If this is the only NIC in the machine then it MUST be replaced with a supported network adapter."
						genevent "E", "3", text
						hardware_cpqnic = 1
						exit function
					end if
				loop
				wshinifile.Close
				screenout "  Check for Compaq Netflex3 NIC on DTC OK."
			else
				screenout ""
				text = "The script was unable to find the DisableNics.ini file!"
				screenout text
				screenout "Make sure that " & scriptinilocvar & " exists and contains the necessary INI file."
				genevent "E", "3", text
				hardware_cpqnic = 1
				exit function
			end if

		else
			screenout ""
			text = "Unable to create a text file in the temporary directory for the script!"
			screenout text
			screenout "Make sure that " & scripttempvar & " exists and is writable."
			screenout "Make sure that ipconfig.exe is available and working properly (ipconfig /all)."
			genevent "E", "3", text
			hardware_cpqnic = 1
			exit function
		end if
	else
		screenout "  Check for Compaq Netflex3 NIC on DTC not needed."
	end if


	if err.number <> 0 then logerror "End of admin_asset Function", err.number : err.clear
	hardware_cpqnic = 0
End Function






REM #################################################################################################
REM ###                                           SSD                                             ###
REM #################################################################################################
Function hardware_ssd()
	dim temp, strcmdline, text, regthere, filethere, servfile, lettervar, locationvar, ended
	dim acufile
	on error resume next

	REM ### SSD ###
	screenout "Compaq SSD (5.03a):"
	if not srvhardwarevar = "COMPAQ"  then
		screenout "  SSD is not needed on this hardware platform."
		cpqssdlogvar = "Different Hardware Platform."
	elseif cpqssdvar = "off"  then
		screenout "  SSD install is disabled."
		cpqssdlogvar = "Disabled"
	elseif cpqssdvar = "switch"  then
		screenout "  SSD install has been disabled by the user."
		cpqssdlogvar = "Disabled - By User"
	else
		temp = WshShell.Regread("HKLM\system\currentcontrolset\services\sysmgmt\imagepath")
		if err.number = 0 then
			regthere = "yes"
		else
			err.clear
			regthere = "no"
		end if
		if (Wshfile.fileexists(cpqssdchkvar)) then
			set servfile = Wshfile.getfile(cpqssdchkvar)
			filethere = datevalue(left(servfile.datelastmodified, Instr(1, servfile.datelastmodified, " ", 1)-1))
			wscript.DisconnectObject servfile
			set servfile=nothing
		else
			filethere = "no"
		end if
		if (Wshfile.fileexists(systemdrive & "\program files\compaq\cpqacu\cpqacu.exe")) then
			set servfile = Wshfile.getfile(systemdrive & "\program files\compaq\cpqacu\cpqacu.exe")
			acufile = datevalue(left(servfile.datelastmodified, Instr(1, servfile.datelastmodified, " ", 1)-1))
			wscript.DisconnectObject servfile
			set servfile=nothing
		else
			acufile = "no"
		end if
		cpqssdfilevar = datevalue(cpqssdfilevar)

		if debug = 1 then screenout "  (SSD Registry: " & regthere & ")"
		if debug = 1 then screenout "  (SSD File: " & filethere & ")"
		if debug = 1 then screenout "  (ACU File: " & acufile & ")"

		if not filethere = "no" and not datecomp(datevalue("1/13/2000"), filethere) then 
			screenout "  Running Primer to remove old utilities and services..."
			screenout "    SNMP may AV during this process so please clear the pop up message if it does."
			screenout "    When the server comes up after the reboot chkdsk may run as well so please let it continue."
			screenout "    Both of these are normal when Primer runs."
			strcmdline = cpqssdlocvar & "\primer\primer s"
			if debug = 1 then screenout "  (" & strcmdline & ")"
			temp = wshshell.Run(strcmdline, 1, true)
			cpqssdlogvar = "Removed"
			wscript.sleep 5000 * netfactor
			screenout ""
			text = "The Primer utility has been ran to remove services and the server must now be rebooted!"
			screenout text
			screenout "CIM will not function properly on a re-install until the server is rebooted."
			screenout "The script will reboot the server after the pop up message is cleared."
			screenout "After the server comes back up, just re-run the script."
		 	genevent "I", "4", text
			genevent "I", "5", "Server was rebooted by " & scriptnamevar & "."
		 	strCmdLine = "cmd /c """& scriptfileslocvar &"\reboot /L /R /T:5"""
		 	temp = wshshell.Run(strcmdline, 0, true)
			hardware_ssd = 1
			exit function
		elseif regthere = "yes" and datecomp(cpqssdfilevar, filethere) and datecomp("5/25/2000", acufile) and (forceupdate = 1 or argument("newcpq") <> 0) then 
			screenout "  Updating Compaq SSD components..."
			cpqssdlogvar = "Updated"
		elseif regthere = "yes" and datecomp(cpqssdfilevar, filethere) and datecomp("5/25/2000", acufile) then 
			screenout "  Compaq SSD components OK."
			screenout "    Running Compaq Advanced System Management Controller Driver(184)..."
			strcmdline = cpqssdlocvar & "\cp000184.exe /s /f"
			if debug = 1 then screenout "      (" & strcmdline & ")"
			temp = wshshell.Run(strcmdline, 1, true)
			screenout "    Running Compaq Integrated System Management Controller Driver(223)..."
			strcmdline = cpqssdlocvar & "\cp000223.exe /s /f"
			if debug = 1 then screenout "      (" & strcmdline & ")"
			temp = wshshell.Run(strcmdline, 1, true)
			screenout "    Running Compaq System Management Controller Driver(224)..."
			strcmdline = cpqssdlocvar & "\cp000224.exe /s /f"
			if debug = 1 then screenout "      (" & strcmdline & ")"
			temp = wshshell.Run(strcmdline, 1, true)
			cpqssdlogvar = "OK"
			hardware_ssd = 0
			exit function
		elseif regthere = "no" then 
			screenout "  Installing Compaq SSD components..."
			cpqssdlogvar = "Installed"
		else
			screenout "  Upgrading Compaq SSD components..."
			cpqssdlogvar = "Upgraded"
		end if
		if (Wshfile.FileExists(cpqssdlocvar & "\CP000224.exe")) and checkfreespace(25) = 0 then
			screenout "    Compaq Advanced System Management Controller Driver(184)..."
			strcmdline = cpqssdlocvar & "\cp000184.exe /s /f"
			if debug = 1 then screenout "      (" & strcmdline & ")"
			temp = wshshell.Run(strcmdline, 1, true)
			screenout "    Compaq Integrated System Management Controller Driver(223)..."
			strcmdline = cpqssdlocvar & "\cp000223.exe /s /f"
			if debug = 1 then screenout "      (" & strcmdline & ")"
			temp = wshshell.Run(strcmdline, 1, true)
			screenout "    Compaq System Management Controller Driver(224)..."
			strcmdline = cpqssdlocvar & "\cp000224.exe /s /f"
			if debug = 1 then screenout "      (" & strcmdline & ")"
			temp = wshshell.Run(strcmdline, 1, true)

			screenout "    Compaq Drive Array Driver(175)..."
			strcmdline = cpqssdlocvar & "\cp000175.exe /s"
			if debug = 1 then screenout "      (" & strcmdline & ")"
			temp = wshshell.Run(strcmdline, 1, false)
			ended = waituntil("cp000175.exe", "")
			ended = waituntil("Upgrade Device Driver Wizard", "cp000175.exe")
			if ended = 0 then 
				screenout "      Clearing Signature pop up..."
				winmanipulate "Upgrade Device Driver Wizard", "Digital Signature Not Found", "%y"
			end if
			ended = waituntil("", "cp000175.exe")

			screenout "    Compaq Smart Array-2 Controllers Driver(176)..."
			strcmdline = cpqssdlocvar & "\cp000176.exe /s"
			if debug = 1 then screenout "      (" & strcmdline & ")"
			temp = wshshell.Run(strcmdline, 1, true)
			screenout "    Compaq 32-Bit SCSI Controller(177)..."
			strcmdline = cpqssdlocvar & "\cp000177.exe /s"
			if debug = 1 then screenout "      (" & strcmdline & ")"
			temp = wshshell.Run(strcmdline, 1, true)
			screenout "    Compaq 64-Bit/66-Mhz Wide Ultra3 Controller Driver(193)..."
			strcmdline = cpqssdlocvar & "\cp000193.exe /s"
			if debug = 1 then screenout "      (" & strcmdline & ")"
			temp = wshshell.Run(strcmdline, 1, true)
			screenout "    Compaq StorageWorks Fibre Channel Host Bus Adapter Driver(178)..."
			strcmdline = cpqssdlocvar & "\cp000178.exe /s"
			if debug = 1 then screenout "       (" & strcmdline & ")"
			temp = wshshell.Run(strcmdline, 1, true)

			screenout "    Compaq NetFlex/Netelligent Adapter Driver(181)..."
			strcmdline = cpqssdlocvar & "\cp000181.exe /s"
			if debug = 1 then screenout "      (" & strcmdline & ")"
			temp = wshshell.Run(strcmdline, 1, false)
			ended = waituntil("cp000181.exe", "")
			ended = waituntil("Upgrade Device Driver Wizard", "cp000181.exe")
			if ended = 0 then 
				screenout "      Clearing Signature pop up..."
				winmanipulate "Upgrade Device Driver Wizard", "Digital Signature Not Found", "%y"
			end if
			ended = waituntil("", "cp000181.exe")
			screenout "      Pausing to wait for network to re-establish..."
			wscript.sleep 12000 * netfactor

			screenout "    Compaq Ethernet or Fast Ethernet NIC Driver(182)..."
			strcmdline = cpqssdlocvar & "\cp000182.exe /s /f"
			if debug = 1 then screenout "      (" & strcmdline & ")"
			temp = wshshell.Run(strcmdline, 1, true)
			screenout "      Pausing to wait for network to re-establish..."
			wscript.sleep 12000 * netfactor

			screenout "    Compaq Gigabit Ethernet NIC Drive(183)..."
			strcmdline = cpqssdlocvar & "\cp000183.exe /s"
			if debug = 1 then screenout "      (" & strcmdline & ")"
			temp = wshshell.Run(strcmdline, 1, true)
			screenout "      Pausing to wait for network to re-establish..."
			wscript.sleep 12000 * netfactor

			screenout "    Compaq Network Teaming and Configuration(195)..."
			strcmdline = cpqssdlocvar & "\cp000195.exe /s"
			if debug = 1 then screenout "      (" & strcmdline & ")"
			temp = wshshell.Run(strcmdline, 1, true)
			screenout "    Compaq ProLiant Storage System Support(179)..."
			strcmdline = cpqssdlocvar & "\cp000179.exe /s"
			if debug = 1 then screenout "      (" & strcmdline & ")"
			temp = wshshell.Run(strcmdline, 1, true)
			screenout "    Compaq Drive Array Notification(180)..."
			strcmdline = cpqssdlocvar & "\cp000180.exe /s"
			if debug = 1 then screenout "      (" & strcmdline & ")"
			temp = wshshell.Run(strcmdline, 1, true)
			screenout "    Compaq Remote Monitor Service(191)..."
			strcmdline = cpqssdlocvar & "\cp000191.exe /s"
			if debug = 1 then screenout "      (" & strcmdline & ")"
			temp = wshshell.Run(strcmdline, 1, true)
			screenout "    Compaq PCI Hot Plug Controller Driver(86)..."
			strcmdline = cpqssdlocvar & "\cp000086.exe /s"
			if debug = 1 then screenout "      (" & strcmdline & ")"
			temp = wshshell.Run(strcmdline, 1, true)
			screenout "    Compaq Integrated Management Display Utility(187)..."
			strcmdline = cpqssdlocvar & "\cp000187.exe /s"
			if debug = 1 then screenout "      (" & strcmdline & ")"
			temp = wshshell.Run(strcmdline, 1, true)
			screenout "    Compaq Integrated Management Log Viewer(186)..."
			strcmdline = cpqssdlocvar & "\cp000186.exe /s"
			if debug = 1 then screenout "      (" & strcmdline & ")"
			temp = wshshell.Run(strcmdline, 1, true)
			screenout "    Compaq Power Supply Viewer(188)..."
			strcmdline = cpqssdlocvar & "\cp000188.exe /s"
			if debug = 1 then screenout "      (" & strcmdline & ")"
			temp = wshshell.Run(strcmdline, 1, true)
			screenout "    Compaq Power Down Manager(189)..."
			strcmdline = cpqssdlocvar & "\cp000184.exe /s"
			if debug = 1 then screenout "      (" & strcmdline & ")"
			temp = wshshell.Run(strcmdline, 1, true)

			REM ###### This module is causing lock ups on DTC servers! ######
			REM screenout "    Compaq Enhanced Integrated Management Display Service(190)..."
			REM strcmdline = cpqssdlocvar & "\cp000190.exe /s"
			REM if debug = 1 then screenout "      (" & strcmdline & ")"
			REM temp = wshshell.Run(strcmdline, 1, true)

			screenout "    Compaq Array Configuration Utility(192)..."
			strcmdline = cpqssdlocvar & "\cp000192.exe /s"
			if debug = 1 then screenout "      (" & strcmdline & ")"
			temp = wshshell.Run(strcmdline, 1, true)
			screenout "    Compaq ATI RAGE IIC Video Controller Support(95)..."
			strcmdline = cpqssdlocvar & "\cp000095.exe /s"
			if debug = 1 then screenout "      (" & strcmdline & ")"
			temp = wshshell.Run(strcmdline, 1, true)
			screenout "    Compaq Remote Insight Board Driver(196)..."
			strcmdline = cpqssdlocvar & "\cp000196.exe /s"
			if debug = 1 then screenout "      (" & strcmdline & ")"
			temp = wshshell.Run(strcmdline, 1, true)
		elseif checkfreespace(25) = 1 then
			text = "There is not enough free space on the boot drive to install SSD!"
			screenout text
			screenout "Please free up 25 MB of disk space on the boot drive and re-run the script."
			genevent "E", "3", text
			hardware_ssd = 1
			exit function
		else
			text = "The script could not locate the SSD setup file!"
			screenout text
			screenout "Make sure the below file exists on the source that you are running the script from."
			screenout "  (" & cpqssdlocvar & "\CP000224.exe)"
			genevent "E", "3", text
			hardware_ssd = 1
			exit Function
		end if
	end if

	if err.number <> 0 then logerror "End of Function hardware_ssd", err.number : err.clear
	hardware_ssd = 0
End Function




REM #################################################################################################
REM ###                                           CIM                                             ###
REM #################################################################################################
Function hardware_cim()
	dim temp, strcmdline, regthere, filethere, servfile, lettervar, locationvar, ended
	on error resume next

	REM ### CIM ###
	screenout "Compaq Insight Manager (4.80):"
	if not srvhardwarevar = "COMPAQ"  then
		screenout "  CIM is not needed on this hardware platform."
		cpqcimlogvar = "Different Hardware Platform."
	elseif cpqcimvar = "off"  then
		screenout "  CIM install is disabled."
		cpqcimlogvar = "Disabled"
	elseif cpqcimvar = "switch"  then
		screenout "  CIM install has been disabled by the user."
		cpqcimlogvar = "Disabled - By User."
	else
		temp = WshShell.Regread("HKLM\system\currentcontrolset\services\cqmgserv\imagepath")
		if err.number = 0 then
			regthere = "yes"
		else
			err.clear
			regthere = "no"
		end if
		if (Wshfile.fileexists(cpqcimchkvar)) then
			set servfile = Wshfile.getfile(systemroot & "\system32\cpqmgmt\CqMgServ\CqMgServ.exe")
			filethere = datevalue(left(servfile.datelastmodified, Instr(1, servfile.datelastmodified, " ", 1)-1))
			wscript.DisconnectObject servfile
			set servfile=nothing
		else
			filethere = "no"
		end if
		cpqcimfilevar = datevalue(cpqcimfilevar)

		if debug = 1 then screenout "  (CIM Registry: " & regthere & ")"
		if debug = 1 then screenout "  (CIM File: " & filethere & ")"

		if regthere = "yes"  and datecomp(cpqcimfilevar, filethere) and (forceupdate = 1 or argument("newcpq") <> 0) then 
			screenout "  Updating Compaq Insight Manager (CIM) Agents..."
			cpqcimlogvar = "Updated"
		elseif regthere = "yes"  and datecomp(cpqcimfilevar, filethere) then 
			screenout "  Compaq Insight Manager (CIM) Agents OK."
			cpqcimlogvar = "OK"
			hardware_cim = 0
			exit function
		elseif regthere = "no" then 
			screenout "  Installing Compaq Insight Manager (CIM) Agents..."
			cpqcimlogvar = "Installed"
		else
			screenout "  Upgrading Compaq Insight Manager (CIM) Agents..."
			cpqcimlogvar = "Upgraded"
		end if

		if (Wshfile.FileExists(cpqcimlocvar & "\cp000150.exe")) and checkfreespace(25) = 0 then
			screenout "    Compaq Foundation Agent(150)..."
			strcmdline = cpqssdlocvar & "\cp000150.exe /s"
			if debug = 1 then screenout "      (" & strcmdline & ")"
			temp = wshshell.Run(strcmdline, 1, true)
			screenout "    Compaq Server Agent(151)..."
			strcmdline = cpqssdlocvar & "\cp000151.exe /s"
			if debug = 1 then screenout "      (" & strcmdline & ")"
			temp = wshshell.Run(strcmdline, 1, true)
			screenout "    Compaq Storage Agent(153)..."
			strcmdline = cpqssdlocvar & "\cp000153.exe /s"
			if debug = 1 then screenout "      (" & strcmdline & ")"
			temp = wshshell.Run(strcmdline, 1, true)
			screenout "    Compaq NIC Agent(152)..."	
			strcmdline = cpqssdlocvar & "\cp000152.exe /s"
			if debug = 1 then screenout "      (" & strcmdline & ")"
			temp = wshshell.Run(strcmdline, 1, true)
			screenout "    Compaq Survey Utility(154)..."
			strcmdline = cpqssdlocvar & "\cp000154.exe /s"
			if debug = 1 then screenout "      (" & strcmdline & ")"
			temp = wshshell.Run(strcmdline, 1, true)

			REM ###### Set CIM Registry entries ######	
			screenout "  Checking CIM registry entries:"
			registry(scriptinilocvar & "\CIMRegistryW2K.ini")
		elseif checkfreespace(25) = 1 then
			screenout ""
			text = "There is not enough free space on the boot drive to install CIM!"
			screenout text
			screenout "Please free up 25 MB of disk space on the boot drive and re-run the script."
			genevent "E", "3", text
			hardware_cim = 1
			exit function
		else
			screenout ""
			text = "The script could not locate the CIM setup file!"
			screenout text
			screenout "Make sure the below file exists on the source that you are running the script from."
			screenout "  (" & cpqcimlocvar & "\cp000150.exe)"
			genevent "E", "3", text
			hardware_cim = 1
			exit Function
		end if
	end if

	if err.number <> 0 then logerror "End of Function", err.number : err.clear
	hardware_cim = 0
End Function





REM #################################################################################################
REM ###                         Compaq Storage Works LP7000 & LP8000 Driver                       ###
REM #################################################################################################
Function hardware_storageworksdriver()
	dim temp, strcmdline, text, wrongfile, filethere, servfile
	dim hubaddress, data
	on error resume next


	REM ### Check for driver dates ###
	screenout "Compaq Storage Works LP Driver (5-4.41A5):"
	if srvstrwrksvar = "ABSENT" then
		screenout "  The Compaq Storage Works LP driver does not exist on this server."
		cpqstrdrvlogvar = "Not installed."
	elseif srvstrwrksvar = "DISABLED" then
		screenout "  The Compaq Storage Works LP driver update has been disabled by the user."
		cpqstrdrvlogvar = "Disabled - By User."
	elseif cpqstrdrvvar = "off" then
		screenout "  The Compaq Storage Works LP driver update is disabled."
		cpqstrdrvlogvar = "Disabled."
	else
		REM ### Get LP driver date ###
		if (Wshfile.fileexists(cpqstrdrvchkvar)) then
			set servfile = Wshfile.getfile(cpqstrdrvchkvar)
			filethere = datevalue(left(servfile.datelastmodified, Instr(1, servfile.datelastmodified, " ", 1)-1))
			wscript.DisconnectObject servfile
			set servfile=nothing
		else
			filethere = "no"
		end if
		cpqstrdrvfilevar = datevalue(cpqstrdrvfilevar)

		if debug = 1 then screenout "  (Storage Works LP File: " & filethere & ")"

		if datecomp(cpqstrdrvfilevar, filethere) and 0 = 1 then
			screenout "  Compaq Storage Works LP driver (" & cpqstrdrvvar & ") OK."
			cpqstrdrvlogvar = "OK"
		else
			screenout "  The Compaq Storage Works LP Driver needs to be updated before the update script can continue!"
			screenout "  The Compaq Storage Works LP Driver needs to be running version " & cpqstrdrvvar & "." 
			screenout "  This requires user intervention! Please follow these steps:"
			screenout "    In 'Device Manager' of 'Computer Manager'"
			screenout "      - Open the 'SCSI and RAID Controllers' Devices"
			screenout "    On the 'Emulex LP6000/7000/8000/9000/850/950, PCI-Fibre Channel Adapter' device"
			screenout "      - Right click and select 'Properties'"
			screenout "    In the 'Emulex LP6000/7000/8000/9000/850/950, PCI-Fibre Channel Adapter' window"
			screenout "      - Select the 'Driver' tab and click on the 'Update Driver' button"
			screenout "    In the 'Upgrade Device Driver Wizard' window"
			screenout "      - Press the 'Next' button"
			screenout "     - Make sure the 'Display a list of known drivers for this device"
			screenout "        so that I can choose a specific driver' radial button is checked"
			screenout "      - Press the 'Next' button"
			screenout "      - Press the 'Have Disk' button"
			screenout "    In the 'Install from Disk' window"
			screenout "      - Press the 'Browse' button"
			screenout "    In the 'Locate File' window"
			screenout "      - Open up the 'Look in' box and select the " & scriptdrivelocvar & " drive"
			screenout "      - Move into the " & cpqstrdrvlocvar & " directory"
			screenout "      - Highlight the 'oemsetup.inf' file"
			screenout "      - Press the 'Open' button"
			screenout "    In the 'Install from Disk' window"
			screenout "      - Press the 'OK' button"
			screenout "    In the 'Upgrade Device Driver Wizard' window"
			screenout "      - Highlight the 'Compaq KGPSA' Model and press the 'Next' button"
			screenout "      - Press the 'Next' button"
			screenout "    In the 'Digital Signature Not Found' window"
			screenout "      - Press the 'Yes' button "
			screenout "   In the 'Upgrade Device Driver Wizard' window"
			screenout "      - Press the 'Finish' button"
			screenout "      - Close out of the properties window"
			screenout "    In the 'System Settings Change' window"
			screenout "      - Press the 'No' button"
			screenout "  Repeat the above steps for ALL Storage Works LP devices!"
			screenout "  Close out of Computer Manager when finished."
			strcmdline = "cmd /c ""compmgmt.msc /s"""	
			temp = wshshell.Run(strcmdline, 0, true)
			cpqstrdrvlogvar = "Upgraded"
		end if
		if instr(1, srvstrwrksvar, "HUB-YES-", 1) <> 0 then
			hubaddress = right(srvstrwrksvar, 4)
			data = "RetryIoTimeOut=1;RetryInterval=52;enabledpc=1;queuetarget=1;queuedepth=25;Topology=0;ScanDown=1;ElsRetryCount=6;SimulateDevice=0;HardALPA=" & hubaddress & ";NodeTimeOut=10;LinkTimeOut=40;HlinkTimeOut=5"
			screenout "  Setting Storage Works SecurePath Hub driver parameter..."
			wshshell.regwrite "HKLM\system\currentcontrolset\services\cqpkgpsa\parameters\device\driverparameter", data, "REG_SZ"
			if err.number <> 0 then logerror "Writing Storage Works SecurePath Hub driver parameter registry location", err.number : err.clear
			logregistryentry "Storage Works SecurePath Hub driver parameter", "Updated", "HKLM\system\currentcontrolset\services\cqpkgpsa\parameters\device\driverparameter", data
		elseif instr(1, srvstrwrksvar, "HUB-NO-", 1) <> 0  then
			hubaddress = right(srvstrwrksvar, 4)
			data = "RetryIoTimeOut=1;RetryInterval=52;enabledpc=1;queuetarget=1;queuedepth=25;NodeTimeout=60;Topology=0;ScanDown=1;ElsRetryCount=6;SimulateDevice=0;HardALPA=" & hubaddress
			screenout "  Setting Storage Works Hub driver parameter..."
			wshshell.regwrite "HKLM\system\currentcontrolset\services\cqpkgpsa\parameters\device\driverparameter", data, "REG_SZ"
			if err.number <> 0 then logerror "Writing Storage Works Hub driver parameter registry location", err.number : err.clear
			logregistryentry "Storage Works Hub driver parameter", "Updated", "HKLM\system\currentcontrolset\services\cqpkgpsa\parameters\device\driverparameter", data
		elseif srvstrwrksvar = "SWITCH-YES" then
			data = "RetryIoTimeOut=1;RetryInterval=52;enabledpc=1;queuetarget=1;queuedepth=25;Topology=1;ElsRetryCount=6;SimulateDevice=0;NodeTimeOut=10;LinkTimeOut=40;HlinkTimeOut=5"
			screenout "  Setting Storage Works SecurePath Switch driver parameter..."
			wshshell.regwrite "HKLM\system\currentcontrolset\services\cqpkgpsa\parameters\device\driverparameter", data, "REG_SZ"
			if err.number <> 0 then logerror "Writing Storage Works SecurePath Switch driver parameter registry location", err.number : err.clear
			logregistryentry "Storage Works SecurePath Switch driver parameter", "Updated", "HKLM\system\currentcontrolset\services\cqpkgpsa\parameters\device\driverparameter", data
		elseif srvstrwrksvar = "SWITCH-NO" then
			data = "RetryIoTimeOut=1;RetryInterval=52;enabledpc=1;queuetarget=1;queuedepth=25;NodeTimeout=60;Topology=1;ElsRetryCount=6;SimulateDevice=0"
			screenout "  Setting Storage Works Switch driver parameter..."
			wshshell.regwrite "HKLM\system\currentcontrolset\services\cqpkgpsa\parameters\device\driverparameter", data, "REG_SZ"
			if err.number <> 0 then logerror "Writing Storage Works Switch driver parameter registry location", err.number : err.clear
			logregistryentry "Storage Works Switch driver parameter", "Updated", "HKLM\system\currentcontrolset\services\cqpkgpsa\parameters\device\driverparameter", data
		end if

	end if

	if err.number <> 0 then logerror "End of hardware_storageworksdriver Function", err.number : err.clear
	hardware_storageworksdriver = 0
End Function




REM #################################################################################################
REM ###                                       Managed Node                                        ###
REM #################################################################################################
Function hardware_managednode(rebootcheck)
	dim temp, strcmdline, text, regthere, filethere, servfile, lettervar, locationvar
	on error resume next

	REM ### Check for  location ###
	screenout "Dell Managed Node (1.52):"
	if not srvhardwarevar = "DELL"  then
		screenout "  Managed Node is not needed on this hardware platform."
		delmannlogvar = "Different Hardware Platform."
	elseif delmannvar = "off"  then
		screenout "  Managed Node install is disabled."
		delmannlogvar = "Disabled"
	elseif delmannvar = "switch"  then
		screenout "  Managed Node install has been turned off by the user."
		delmannlogvar = "Disabled - By User"
	else
		if (Wshfile.fileexists(systemroot & "\system32\msvcrt.old")) then wshfile.deletefile systemroot & "\system32\msvcrt.old", TRUE
		if err.number <> 0 then err.clear
		temp = WshShell.Regread("HKLM\system\currentcontrolset\services\dell baseboard agent\imagepath")
		if err.number = 0 then
			regthere = "yes"
		else
			err.clear
			regthere = "no"
		end if
		if (Wshfile.fileexists(delmannchkvar)) then
			set servfile = Wshfile.getfile(delmannchkvar)
			filethere = datevalue(left(servfile.datelastmodified, Instr(1, servfile.datelastmodified, " ", 1)-1))
			wscript.DisconnectObject servfile
			set servfile=nothing
		else
			filethere = "no"
		end if
		delmannfilevar = datevalue(delmannfilevar)

		if debug = 1 then screenout "  (DMN Registry: " & regthere & ")"
		if debug = 1 then screenout "  (DMN File: " & filethere & ")"

		if regthere = "yes" and not datecomp(delmannfilevar, filethere) then
			screenout ""
			text = "Dell Managed Node needs to be removed before the update script can continue!"
			screenout text
			screenout "Removing Dell Managed Node requires user intervention."
			screenout "To remove Version 1.50, follow these steps:"
			screenout "  - Go to Start - Programs - 'Dell OpenManage Applications'"
			screenout "  - Select 'Uninstall NNM Se Components'."
			screenout "  - Press 'OK'."
			screenout "  - Press 'ALL'."
			screenout "  - Press 'OK'."
			screenout "  - Press 'OK', when the removal is complete."
			screenout "  - Press 'No' to reboot the server."
			screenout "Other versions may be named different but the procedure is still the same."
			screenout ""
			genevent "W", "3", text
			hardware_managednode = 1
			exit function
		elseif rebootcheck then 
			screenout "  The reboot check for Dell Managed Node is OK."
			hardware_managednode = 0
			exit function
		elseif regthere = "yes" and datecomp(delmannfilevar, filethere) then 
			screenout "  Dell Managed Node OK."
			delmannlogvar = "OK"
			hardware_managednode = 0
			exit function
		elseif regthere = "no" then
			screenout "  Installing Dell Managed Node..."
			delmannlogvar = "Installed"
		else 
			screenout "  Upgrading Dell Managed Node..."
			delmannlogvar = "Upgraded"
		end if
		if (Wshfile.FileExists(delmannlocvar & "\setup.exe")) and checkfreespace(25) = 0 then
			screenout "  This requires user intervention! Please follow these steps:"
			screenout "  In the 'Dell OpenManage Master Setup' screen:"
			screenout "    - Use all defaults"
			screenout "    - Press the 'Next' Button"
			screenout "  In the 'License' screen:"
			screenout "    - Press the 'I agree' button"
			screenout "  In the 'Dell OpenManage Managed Node Setup' screen:"
			screenout "    - Select 'Dell Managed Node for Windows NT'"
			screenout "    - Press the 'Install' button"
			screenout "  In the 'Dell OpenManage Managed Node Manager - Windows NT' screen:"
			screenout "    - Press the 'OK' button"
			screenout "  In the 'Dell OpenManage Connection Setup' screen:"
			screenout "    - Press the 'No' button"
			lettervar = left(delmannlocvar, Instr(1, delmannlocvar, ":", 1))
			locationvar = right(delmannlocvar, len(delmannlocvar)-2)
			strcmdline = "cmd /c """& lettervar & "& cd " & locationvar & "&" & " setup.exe & " & systemdrive & """"
			if debug = 1 then screenout "  (" & strcmdline & ")"
			temp = wshshell.Run(strcmdline, 0, true)
			if (Wshfile.fileexists(systemroot & "\system32\msvcrt.dlltcb")) then 
				screenout "  Removing file msvcrt.dlltcb..."
				wshfile.deletefile systemroot & "\system32\msvcrt.dlltcb", TRUE
			end if
			if err.number <> 0 then err.clear
		elseif checkfreespace(25) = 1 then
			screenout ""
			text = "There is not enough free space on the boot drive to install Managed node!"
			screenout text
			screenout "Please free up 25 MB of disk space on the boot drive and re-run the script."
			genevent "E", "3", text
			hardware_managednode = 1
			exit function
		else
			screenout ""
			text = "The script could not locate the Managed Node setup file!"
			screenout text
			screenout "Make sure the below file exists on the source that you are running the script from."
			screenout "  (" & delmannlocvar & "\setup.exe)"
			genevent "E", "3", text
			hardware_managednode = 1
			exit Function
		end if
	end if

	if err.number <> 0 then logerror "End of hardware_managednode Function", err.number : err.clear
	hardware_managednode = 0
End Function




REM #################################################################################################
REM ###                                       Perc2 Fast                                          ###
REM #################################################################################################
Function hardware_perc2fast(rebootcheck)
	dim temp, strcmdline, text, regthere, filethere, servfile, lettervar, locationvar
	on error resume next

	REM ### Check for  location ###
	screenout "Dell FAST Utility (2.1 - 2972):"
	if not srvhardwarevar = "DELL"  then
		screenout "  The FAST utility is not needed on this hardware platform."
		delfastlogvar = "Different Hardware Platform."
	elseif delfastvar = "off"  then
		screenout "  The Fast Utility install is disabled."
		delfastlogvar = "Disabled"
	elseif delfastvar = "switch"  then
		screenout "  The Fast Utility install has been turned off by the user."
		delfastlogvar = "Disabled - By User"
	else
		temp = WshShell.Regread("HKLM\system\currentcontrolset\services\afa_agent\imagepath")
		if err.number = 0 then
			regthere = "yes"
		else
			err.clear
			regthere = "no"
		end if
		if (Wshfile.fileexists(delfastchkvar)) then
			set servfile = Wshfile.getfile(delfastchkvar)
			filethere = datevalue(left(servfile.datelastmodified, Instr(1, servfile.datelastmodified, " ", 1)-1))
			wscript.DisconnectObject servfile
			set servfile=nothing
		else
			filethere = "no"
		end if
		delfastfilevar = datevalue(delfastfilevar)

		if debug = 1 then screenout "  (FAST Registry: " & regthere & ")"
		if debug = 1 then screenout "  (FAST File: " & filethere & ")"

		if regthere = "yes" and not datecomp(delfastfilevar, filethere) then
			screenout ""
			text = "Dell FAST needs to be removed before the update script can continue!"
			screenout text
			screenout "The old version must be removed before the new version can be installed."
			screenout "Removing Dell FAST requires user intervention."
			screenout "To remove Version 2941, follow these steps:"
			screenout "  - Go to Start - Settings - 'Control Panel'"
			screenout "  - Select 'Add/Remove Programs'."
			screenout "  - Highligh 'Dell Perc 2'."
			screenout "  - Press the 'Change/Remove' button."
			screenout "  - Press 'Yes'."
			screenout "  - Press 'Yes'."
			screenout "      (If the uninstall script hangs, close out of the .cmd window and re-start it.)"
			screenout "  - Press 'OK'."
			screenout "  - Close out of 'Add/Remove Programs' and 'Control Panel'."
			screenout "Other versions may be named different but the procedure is still the same."
			screenout ""
			genevent "W", "3", text
			hardware_perc2fast = 1
			exit function
		elseif rebootcheck then 
			screenout "  The reboot check for Dell FAST is OK."
			hardware_perc2fast = 0
			exit function
		elseif regthere = "yes" and datecomp(delfastfilevar, filethere) then 
			screenout "  Dell FAST OK."
			delfastlogvar = "OK"
			hardware_perc2fast = 0
			exit function
		elseif regthere = "no" then
			screenout "  Installing Dell FAST..."
			if debug = 1 then screenout "    (FAST Registry: " & regthere & ")"
			if debug = 1 then screenout "    (FAST File: " & filethere & ")"
			delfastlogvar = "Installed"
		else
			screenout "  Upgrading Dell FAST..."
			if debug = 1 then screenout "    (FAST Registry: " & regthere & ")"
			if debug = 1 then screenout "    (FAST File: " & filethere & ")"
			delfastlogvar = "Upgraded"
		end if
		if (Wshfile.FileExists(delfastlocvar & "\setup.exe")) and checkfreespace(25) = 0 then
			screenout "  This requires user intervention! You will need to:"
			screenout "  In the 'Welcome to the setup of Dell Perc 2' screen:"
			screenout "    - Press the 'Next' Button"
			screenout "  In the 'User Information' screen:"
			screenout "    - Press the 'Next' button"
			screenout "  In the 'Select Program Folder' screen:"
			screenout "    - Press the 'Next' button"
			screenout "  In the 'Dell Perc2; 2/Si; 3/Di; 3/Si Setup: Destination Base Directory Selection' screen:"
			screenout "    - Press the 'Next' button"
			screenout "  In the 'Installation Type Selection' screen:"
			screenout "    - Press the 'Next' button"
			screenout "  In the 'Start Copying Files' screen:"
			screenout "    - Press the 'Next' button"
			screenout "  In the 'Question' screen:"
			screenout "    - Press the 'No' button"
			screenout "  In the 'Dell Perc2; 2/Si; 3/Di; 3/Si Setup Complete' screen:"
			screenout "    - Select the 'No, I will restart my computer later' radial button"
			screenout "    - Press the 'Finish' button"
			lettervar = left(delfastlocvar, Instr(1, delfastlocvar, ":", 1))
			locationvar = right(delfastlocvar, len(delfastlocvar)-2)
			strcmdline = "cmd /c """& lettervar & "& cd " & locationvar & "&" & " setup.exe & " & systemdrive & """"
			if debug = 1 then screenout "    (" & strcmdline & ")"
			temp = wshshell.Run(strcmdline, 0, true)
			waituntil "", "Dell PERC 2; 2/Si; 3/Di; 3/Si Setup"
			screenout "  Setting all Perc2 array controllers write cache to Always on..."
			strcmdline = "cmd /c """""& systemdrive & "\program files\perc2\afa\afacli"" @" & delfastlocvar & "\cacheon.afa"""
			if debug = 1 then screenout "    (" & strcmdline & ")"
			temp = wshshell.Run(strcmdline, 1, true)
		elseif checkfreespace(25) = 1 then
			screenout ""
			text = "There is not enough free space on the boot drive to install the FAST Utility!"
			screenout text
			screenout "Please free up 25 MB of disk space on the boot drive and re-run the script."
			genevent "E", "3", text
			hardware_perc2fast = 1
			exit function
		else
			screenout ""
			text = "The script could not locate the Fast Utility setup file!"
			screenout text
			screenout "Make sure the below file exists on the source that you are running the script from."
			screenout "  (" & delfastlocvar & "\setup.exe)"
			genevent "E", "3", text
			hardware_perc2fast = 1
			exit Function
		end if
	end if

	if err.number <> 0 then logerror "End of hardware_perc2fast Function", err.number : err.clear
	hardware_perc2fast = 0
End Function




REM #################################################################################################
REM ###                                    Recovery Console                                        ###
REM #################################################################################################
Function update_reccons()
	dim temp, strcmdline, text, servfile, filethere
	on error resume next

	REM ### Check for Recovery Console location ###
	screenout "Recovery Console:"
	if recconsvar = "off"  then
		screenout "  Recovery Console install is disabled."
		recconslogvar = "Disabled"
	elseif recconsvar = "switch"  then
		screenout "  Recovery Console install has been disabled by the user."
		recconslogvar = "Disabled - By User"
	elseif not srvbootvar = "NTFS" then
		screenout "  Recovery Console does not need installed on Non-NTFS partitions."
		recconslogvar = "Non-NTFS Boot Partition"
	else
		if not recconsfilevar = "" then
		elseif recconsfilevar = "" and (Wshfile.fileexists(bldlocvar & "\" & srvarcvar & "\autochk.exe")) then
			set servfile = Wshfile.getfile(bldlocvar & "\" & srvarcvar & "\autochk.exe")
			recconsfilevar = left(servfile.datelastmodified, Instr(1, servfile.datelastmodified, " ", 1)-1)
			wscript.DisconnectObject servfile
			set servfile=nothing
			if err.number <> 0 then err.clear
		else
			screenout ""
			text = "The script could not locate the Recovery Console check file!"
			screenout text
			screenout "  (" & bldlocvar & "\" & srvarcvar & "\autochk.exe" & ")"
			recconslogvar = "No Check File"
			genevent "E", "3", text
			update_reccons = 1
			exit function
		end if
		if (Wshfile.fileexists(recconschkvar)) then
			set servfile = Wshfile.getfile(recconschkvar)
			filethere = datevalue(left(servfile.datelastmodified, Instr(1, servfile.datelastmodified, " ", 1)-1))
			wscript.DisconnectObject servfile
			set servfile=nothing
			if err.number <> 0 then err.clear
		else
			filethere = "no"
		end if
		recconsfilevar = datevalue(recconsfilevar)

		if debug = 1 then screenout "  (Source File: " & recconsfilevar & ")"
		if debug = 1 then screenout "  (Check File: " & filethere & ")"

		if datecomp(recconsfilevar, filethere) and forceupdate = 1  then 
			screenout "  Updating Recovery Console..."
			recconslogvar = "Updated"
		elseif datecomp(recconsfilevar, filethere) then 
			screenout "  Recovery Console OK."
			recconslogvar = "OK"
			update_reccons = 0
			exit function
		elseif filethere = "no" then 
			screenout "  Installing Recovery Console..."
			recconslogvar = "Installed"
		else
			screenout "  Upgrading Recovery Console..."
			recconslogvar = "Upgraded"
		end if
		if (Wshfile.FileExists(recconslocvar)) then
			strcmdline = recconslocvar & " /cmdcons"
			if debug = 1 then screenout "  (" & strcmdline & ")"
			temp = wshshell.Run(strcmdline, 1, false)
			screenout "      Waiting for Recovery Console to start..."
			waituntil "Windows 2000 Setup", ""
			screenout "      Starting Recovery Console file copy..."
			winmanipulate "Windows 2000 Setup", "Windows 2000 Setup", "Y"
			screenout "      Waiting for copy to complete..."
			waituntil "Microsoft Windows 2000 Advanced Server Setup", "winnt32.exe"
			wscript.sleep 25000 * netfactor
			screenout "      Closing out of Recovery Console..."
			winmanipulate "Microsoft Windows 2000 Advanced Server Setup", "Microsoft Windows 2000 Advanced Server Setup", "{ENTER}"
			if err.number <> 0 then err.clear

			REM ###### Set Reccons Registry entries ######	
			screenout "Setting Recovery Console registry entries..."
			registry(scriptinilocvar & "\RecconsRegistryW2K.ini")
		else
			screenout ""
			text = "The script could not locate the Recovery Console setup file!"
			screenout text
			screenout "  (" & recconslocvar & ")"
			recconslogvar = "No Install File"
			genevent "E", "3", text
			update_reccons = 1
			exit function
		end if
	end if

	if err.number <> 0 then logerror "End of update_reccons Function", err.number : err.clear
	update_reccons = 0
End Function




REM #################################################################################################
REM ###                                  Service Pack                                             ###
REM #################################################################################################
Function update_sp(rebootcheck)
	dim temp, strcmdline, text, srvsp, srvrc, scriptsp, scriptrc, backup, servfile, filethere
	on error resume next

	REM ### Install service Pack ###
	screenout "Service Pack 1:"
	if spvar = "off" then
		screenout "  Service Pack install is disabled at this time."
		splogvar = "Disabled"
	elseif spvar = "switch" then 
		screenout "  Service Pack install has been turned off by the user."
		splogvar = "Disabled - By User"
	elseif spdirvar = "SP0" then 
		screenout "  No Service Pack install at this time."
		splogvar = "None"
	else
		if Instr(1, spdirvar, "SP", 1) <> 0 and Instr(1, spdirvar, ".", 1) <> 0 then
			scriptsp = int(mid(spdirvar, 3, 1))
			scriptrc = int(right(spdirvar, 3))
		elseif Instr(1, spdirvar, "SP", 1) = 0 and Instr(1, spdirvar, ".", 1) <> 0 then
			scriptsp = 0
			scriptrc = int(right(spdirvar, 3))
		elseif Instr(1, spdirvar, "SP", 1) <> 0 and Instr(1, spdirvar, ".", 1) = 0 then
			scriptsp = int(mid(spdirvar, 3, 1))
			scriptrc = 0
		else
			scriptsp = 0
			scriptrc = 0
		end if
		if Instr(1, srvcsdvar, "Service Pack", 1) <> 0 and Instr(1, srvcsdvar, "RC", 1) <> 0 then
			srvsp = int(mid(srvcsdvar, 14, 1))
			srvrc = int(right(srvcsdvar, len(srvcsdvar) - Instr(1, srvcsdvar, ".", 1)))
		elseif Instr(1, srvcsdvar, "Service Pack", 1) = 0 and Instr(1, srvcsdvar, "RC", 1) <> 0 then
			srvsp = 0
			srvrc = int(right(srvcsdvar, len(srvcsdvar) - Instr(1, srvcsdvar, ".", 1)))
		elseif Instr(1, srvcsdvar, "Service Pack", 1) <> 0 and Instr(1, srvcsdvar, "RC", 1) = 0 then
			srvsp = int(mid(srvcsdvar, 14, 1))
			srvrc = 0
		else
			srvsp = 0
			srvrc = 0
		end if
		if (Wshfile.fileexists(spchkvar)) then
			set servfile = Wshfile.getfile(spchkvar)
			filethere = datevalue(left(servfile.datelastmodified, Instr(1, servfile.datelastmodified, " ", 1)-1))
			wscript.DisconnectObject servfile
			set servfile=nothing
			if err.number <> 0 then err.clear
		else
			filethere = "no"
		end if
		if (Wshfile.folderexists(systemroot & "\$NtServicePackUninstall$")) then 
			backup = "yes"
		else
			backup = "no"
		end if
		if debug = 1 then screenout "  (Script SP: " & scriptsp & ")"
		if debug = 1 then screenout "  (Server SP: " & srvsp & ")"
		if debug = 1 then screenout "  (SP Backup: " & backup & ")"
		if debug = 1 then screenout "  (SP File: " & filethere & ")"

 
		if srvsp > scriptsp then 
			screenout ""
			text = "This server is all ready running Service Pack " & srvsp & " which is newer then what this script supports!"
			screenout text
			screenout "You must run an update script that supports this Service Pack or remove the current SP."
			screenout ""
			genevent "E", "3", text
			update_sp = 1
			exit function
		elseif srvsp = scriptsp and not backup = "no" then 
			screenout ""
			text = "This server is all ready running Service Pack " & srvsp & " with a backup directory!"
			screenout text
			screenout "You must remove the current SP before running the update script again."
			screenout "You can remove the current SP by using Control Panel - Add/remove programs."
			screenout ""
			genevent "E", "3", text
			update_sp = 1
			exit function
		elseif rebootcheck then 
			screenout "  The reboot check for Service Pack " & scriptsp & " is OK."
			update_sp = 0
			exit function
		elseif srvsp = scriptsp and datecomp(spfilevar, filethere) and forceupdate = 1 then 
			screenout "  Updating Service Pack " & scriptsp & "..."
			splogvar = "Updated"
			update_sp = 0
			exit function
		elseif srvsp = scriptsp and datecomp(spfilevar, filethere) then 
			screenout "  Service Pack " & scriptsp & " OK."
			splogvar = "OK"
			update_sp = 0
			exit function
		elseif srvsp = 0 then 
			screenout "  Installing Service Pack " & scriptsp & "..."
			splogvar = "Installed"
		else
			screenout "  Upgrading to Service Pack " & scriptsp & "..."
			splogvar = "Upgraded"
		end if

		if (Wshfile.FileExists(splocvar & "\" & srvarcvar & "\update\update.exe")) and checkfreespace(60) = 0 then
			strcmdline = splocvar & "\" & srvarcvar & "\update\update.exe -u -n -o -z"
			rem strcmdline = splocvar & "\" & srvarcvar & "\update\update.exe -u -o -z"
			if debug = 1 then screenout "  (" & strcmdline & ")"
			temp = wshshell.Run(strcmdline, 1, true)
		elseif checkfreespace(60) = 1 then
			screenout ""
			text = "There is not enough free space on the boot drive to install the Service Pack!"
			screenout text
			screenout "Please free up 60 MB of disk space on the boot drive and re-run the script."
			genevent "E", "3", text
			update_sp = 1
			exit function
		else
			screenout ""
			text = "The script could not locate the Service Pack setup file!"
			screenout text
			screenout "Make sure the below file exists on the source that you are running the script from."
			screenout "  (" & splocvar & "\" & srvarcvar & "\update\update.exe)"
			genevent "E", "3", text
			update_sp = 1
			exit Function
		end if
	end if

	if err.number <> 0 then logerror "End of update_sp Function", err.number : err.clear
	update_sp = 0
End Function



REM #################################################################################################
REM ###                                  Symbols                                                  ###
REM #################################################################################################
Function update_sym()
	dim text, wshinifile, file, strcmdline, temp
	on error resume next

	REM ### Install Symbols ###
	screenout "Symbols:"
	if (Wshfile.folderexists(systemroot & "\symbolsold")) then wshfile.deletefolder systemroot & "\symbolsold", TRUE
	if err.number <> 0 then err.clear
	if symvar = "off" then
		screenout "  Symbol install is disabled."
		symlogvar="Disabled"
	elseif symvar = "switch" then
		screenout "  Symbol install has been disabled by the user."
		symlogvar = "Disabled - By User"
	elseif symvar = "no" then
		screenout "  Symbol install not needed at this site."
		symlogvar = "Disabled - By Site"
	else
		screenout "  Removing Windows 2000 Symbol directories..."
		if (Wshfile.folderexists(systemroot & "\symbols\acm")) then wshfile.deletefolder systemroot & "\symbols\acm", TRUE
		if (Wshfile.folderexists(systemroot & "\symbols\ax")) then wshfile.deletefolder systemroot & "\symbols\ax", TRUE
		if (Wshfile.folderexists(systemroot & "\symbols\cfm")) then wshfile.deletefolder systemroot & "\symbols\cfm", TRUE
		if (Wshfile.folderexists(systemroot & "\symbols\cnv")) then wshfile.deletefolder systemroot & "\symbols\cnv", TRUE
		if (Wshfile.folderexists(systemroot & "\symbols\cpl")) then wshfile.deletefolder systemroot & "\symbols\cpl", TRUE
		if (Wshfile.folderexists(systemroot & "\symbols\ds")) then wshfile.deletefolder systemroot & "\symbols\ds", TRUE
		if (Wshfile.folderexists(systemroot & "\symbols\flg")) then wshfile.deletefolder systemroot & "\symbols\flg", TRUE
		if (Wshfile.folderexists(systemroot & "\symbols\io")) then wshfile.deletefolder systemroot & "\symbols\io", TRUE
		if (Wshfile.folderexists(systemroot & "\symbols\scr")) then wshfile.deletefolder systemroot & "\symbols\scr", TRUE
		if (Wshfile.folderexists(systemroot & "\symbols\tsp")) then wshfile.deletefolder systemroot & "\symbols\tsp", TRUE
		if (Wshfile.folderexists(systemroot & "\symbols\usa")) then wshfile.deletefolder systemroot & "\symbols\usa", TRUE
		if (Wshfile.folderexists(systemroot & "\symbols\wpc")) then wshfile.deletefolder systemroot & "\symbols\wpc", TRUE
		if (Wshfile.folderexists(systemroot & "\symbols\16bit")) then wshfile.deletefolder systemroot & "\symbols\16bit", TRUE
		if (Wshfile.folderexists(systemroot & "\symbols\winnt32")) then wshfile.deletefolder systemroot & "\symbols\winnt32", TRUE
		if (Wshfile.folderexists(systemroot & "\symbols\noexport")) then wshfile.deletefolder systemroot & "\symbols\noexport", TRUE
		if err.number <> 0 then logerror "Deleting Symbols directories", err.number : err.clear
		if (Wshfile.fileexists(scriptinilocvar & "\SymbolFilesW2K.ini")) then 
			Set wshinifile = wshfile.OpenTextFile(scriptinilocvar & "\SymbolFilesW2K.ini", 1)
			screenout "  Removing Windows 2000 Symbol files..."
			Do While wshinifile.AtEndOfStream <> true
				file = wshiniFile.ReadLine
				if (Wshfile.FileExists(systemroot & file)) then
					rem screenout "    " & file
					wshfile.deletefile systemroot & file, TRUE
					if err.number <> 0 then err.clear
				end if
			loop
			wshinifile.Close
		else
			screenout ""
			text = "The script was unable to find the SymbolFilesW2K.ini file!"
			screenout text
			screenout "Make sure that " & scriptinilocvar & " exists and contains the necessary INI file."
			genevent "E", "3", text
			update_sym = 1
			exit function
		end if
		if symvar = "clear" then
			screenout "  Symbols have been cleared by the user."
			symlogvar = "Cleared - By User"
		elseif scriptsitevar = "DESK" then
			screenout "  Symbols do not need installed on Desk Top machines."
			symlogvar = "Desk Top Machine"
		elseif symvar = "full" and checkfreespace(750) = 0 then
			if not (Wshfile.folderexists(systemroot & "\symbols")) then wshfile.createfolder systemroot & "\symbols", TRUE
			screenout "  Starting FULL Symbol set copy..."
			symlogvar="Installed FULL set"
			strcmdline = "cmd /c ""xcopy /cdefhkrvyz " & symfulllocvar & " " & systemroot & "\symbols\"""
	       		if debug = 1 then screenout "    (" & strcmdline & ")"
               		temp = wshshell.Run(strcmdline, 1, true)
			if temp <> 0 then 
				screenout ""
				text = "The script was unable to complete the symbol files copy to the " & systemroot & "\symbols directory!"
				screenout text
				screenout "Make sure the directory or a file in the directory is not in use by an application."
				screenout "Do not close the Command Prompt window that is copying files."
				screenout "Try removing the symbols directory from the server and run the script again."
				genevent "E", "3", text
				update_sym = 1
				exit function
			end if
		elseif checkfreespace(80) = 0  then
			if not (Wshfile.folderexists(systemroot & "\symbols")) then wshfile.createfolder systemroot & "\symbols", TRUE
			screenout "  Starting SMALL Symbol set copy..."
			symlogvar="Installed SMALL set"
			strcmdline = "cmd /c ""xcopy /cdefhkrvyz " & symlocvar & " " & systemroot & "\symbols\"""
	       		if debug = 1 then screenout "    (" & strcmdline & ")"
			temp = wshshell.Run(strcmdline, 1, true)
			if temp <> 0 then 
				screenout ""
				text = "The script was unable to complete the symbol files copy to the " & systemroot & "\symbols directory!"
				screenout text
				screenout "Make sure the directory or a file in the directory is not in use by an application."
				screenout "Do not close the Command Prompt window that is copying files."
				screenout "Try removing the symbols directory from the server and run the script again."
				genevent "E", "3", text
				update_sym = 1
				exit function
			end if
			if not wwwvar = "" then screenout "  Starting IIS Symbol copy..."
			if not wwwvar = "" then symlogvar="Installed SMALL set and IIS small set"
			if not wwwvar = "" then strcmdline = "cmd /c ""xcopy /cdefhkrvyz " & wwwsymlocvar & " " & systemroot & "\symbols\"""
	       		if not wwwvar = "" and debug = 1 then screenout "    (" & strcmdline & ")"
			if not wwwvar = "" then temp = wshshell.Run(strcmdline, 1, true)
			if not wwwvar = "" and err.number <> 0 then err.clear
		else
			screenout ""
			text = "There is not enough free space on the boot drive to install symbols!"
			screenout text
			screenout "Please free up 80 MB on the boot drive for the small symbol set (750 MB for the Full symbols set)."
			genevent "E", "3", text
			update_sym = 1
			exit function
		end if
	end if

	if err.number <> 0 then logerror "End of update_sym Function", err.number : err.clear
	update_sym = 0
End Function



REM #################################################################################################
REM ###                                  Hotfixes                                                 ###
REM #################################################################################################
Function update_fix()
	dim temp, strcmdline, text, wshinifile, rkey, dchotfixes
	on error resume next

	REM ### install Hotfixes ###
	screenout "Hotfixes:"
	if fixvar = "off" then
		screenout "  Hotfix install is disabled."
		fixlogvar = "Disabled"
	elseif fixvar = "switch" then
		screenout "  Hotfix install has been turned off by the user."
		fixlogvar = "Disabled - By User"
	else
		screenout "  Clearing IPAK tracking registry entries (For Tools and Update script)..."
		if (Wshfile.fileexists(scriptinilocvar & "\DeleteRegKeysW2K.ini")) then 
			Set wshinifile = wshfile.OpenTextFile(scriptinilocvar & "\DeleteRegKeysW2K.ini", 1)
			Do While wshinifile.AtEndOfStream <> true
				rkey = wshiniFile.ReadLine
				wshshell.regdelete rkey
				if err.number <> 0 then err.clear
			loop
			wshinifile.Close
		else
			screenout ""
			text = "The script was unable to find the DeleteRegKeysW2K.ini file!"
			screenout text
			screenout "Make sure that " & scriptinilocvar & " exists and contains the necessary INI file."
			genevent "E", "3", text
			update_fix = 1
			exit function
		end if
		screenout "  Clearing Hotfix tracking registry entries (For srvinfo)..."
		if (Wshfile.fileexists(scriptinilocvar & "\DelhotfixRegKeysW2K.ini")) then 
			Set wshinifile = wshfile.OpenTextFile(scriptinilocvar & "\DelhotfixRegKeysW2K.ini", 1)
			Do While wshinifile.AtEndOfStream <> true
				rkey = wshiniFile.ReadLine
				rem if debug = 1 then screenout "    (" & rkey & ")"
				strCmdLine = "cmd /c """& scriptfileslocvar & "\reg delete """ & rkey & """ /f"""
				rem if debug = 1 then screenout "    (" & strcmdline & ")"
				temp = wshshell.Run(strcmdline, 0, true)
				if err.number <> 0 then err.clear
			loop
			wshinifile.Close
		else
			screenout ""
			text = "The script was unable to find the DelhotfixRegKeysW2K.ini file!"
			screenout text
			screenout "Make sure that " & scriptinilocvar & " exists and contains the necessary INI file."
			genevent "E", "3", text
			update_fix = 1
			exit function
		end if
		if (Wshfile.FileExists(fixlocvar & "\hotfix.exe")) then
			screenout "  Installing Hotfixes..."
			fixlogvar = "Installed"
			strcmdline = fixlocvar & "\hotfix.exe -n -z -m"
	       		if debug = 1 then screenout "    (" & strcmdline & ")"
               		temp = wshshell.Run(strcmdline, 1, true)
		else
			screenout "  No Hotfixes at this time."
			fixlogvar = "None"
		end if
		if (Wshfile.FileExists(fixlocvar & "\hftrack.exe")) then
			screenout "  Installing Hotfix and IPAK tracking registry entries..."
			strcmdline = fixlocvar & "\hftrack.exe"
	       		if debug = 1 then screenout "    (" & strcmdline & ")"
               		temp = wshshell.Run(strcmdline, 1, true)
		else
			screenout ""
			text = "The script could not locate the HfTrack setup file!"
			screenout text
			screenout "Make sure that the HfTrack.exe file is located at the below location."
			screenout "    (" & fixlocvar & "\hftrack.exe)"
			genevent "E", "3", text
			update_fix = 1
			exit function
		end if
		dchotfixes = scriptpathlocvar & "\" & srvbuildvar & "\" & srvsuitevar & "\" & srvarcvar & "\" & spdirvar & "\hotfix\dcfixes"
		if argument("/allfixes") <> 0 and (Wshfile.FileExists(scriptcmdlocvar & "\allfixes.vbs")) then
			screenout "  Installing All additional Hotfixes..."
			strcmdline = "cmd /c """ & scriptcmdlocvar & "\allfixes.vbs"""
	       		if debug = 1 then screenout "    (" & strcmdline & ")"
               		temp = wshshell.Run(strcmdline, 1, true)
		elseif srvrolevar = "Domain Controller" and (Wshfile.FileExists(dchotfixes & "\setup.cmd")) then
			screenout "  Installing additional DC Hotfixes..."
			strcmdline = "cmd /c """ & dchotfixes & "\setup.cmd"""
	       		if debug = 1 then screenout "    (" & strcmdline & ")"
               		temp = wshshell.Run(strcmdline, 1, true)
		elseif argument("/allfixes") <> 0 then
			screenout "  No additional Hotfixes."
		end if
	end if

	if err.number <> 0 then logerror "End of update_fix Function", err.number : err.clear
	update_fix = 0
End Function



REM #################################################################################################
REM ###                                  128 Bit encryption                                       ###
REM #################################################################################################
Function update_128()
	dim temp, strcmdline, text
	on error resume next

	REM ### Run 128 bit encryption script ###
	screenout "128 bit encryption:"
	if encvar="off" then
		screenout "  128 Bit encryption is disabled."
		enclogvar = "Disabled"
	elseif encvar= "switch" then
		screenout "  128 Bit encryption disabled by the user."
		enclogvar = "Disabled - By User"
	else
		if (Wshfile.FileExists(enclocvar)) then
			screenout "  Starting 128 Bit Encryption IPAK script..."
			enclogvar = "Executed"
			strcmdline = "cmd /c """ & enclocvar & " /noreb"""
			if debug = 1 then screenout "  (" & strcmdline & ")"
			temp = wshshell.Run(strcmdline, 1, true)
		else
			screenout ""
			text = "The script could not locate the 128 Bit encryption script!"
			screenout text
			screenout "Make sure that this site supports 128 bit encryption."
			screenout "Make sure that the 128 bit encryption script has been replicated to this server."
			screenout "  (" & enclocvar & ")"
			enclogvar = "No Script"
			genevent "E", "3", text
			update_128 = 1
			exit function
		end if
	end if

	if err.number <> 0 then logerror "End of update_128 Function", err.number : err.clear
	update_128 = 0
End Function





REM #################################################################################################
REM ###                                       Localbin Files                                      ###
REM #################################################################################################
Function file_localbin()
	dim strcmdline, temp, text, servfile, filethere, bincheckfile
	on error resume next

	screenout "Localbin Files:"
	if (Wshfile.folderexists(systemdrive & "\localold")) then wshfile.deletefolder systemdrive & "\localold", TRUE
	if err.number <> 0 then err.clear
	if (Wshfile.fileexists(scriptbinlocvar & "\binupdate.log")) then
		set servfile = Wshfile.getfile(scriptbinlocvar & "\binupdate.log")
		bincheckfile = left(servfile.datelastmodified, Instr(1, servfile.datelastmodified, " ", 1)-1)
		wscript.DisconnectObject servfile
		set servfile=nothing
		if err.number <> 0 then err.clear
	else
		bincheckfile = "no"
	end if
	if (Wshfile.fileexists(scriptbinvar & "\binupdate.log")) then
		set servfile = Wshfile.getfile(scriptbinvar & "\binupdate.log")
		filethere = datevalue(left(servfile.datelastmodified, Instr(1, servfile.datelastmodified, " ", 1)-1))
		wscript.DisconnectObject servfile
		set servfile=nothing
		if err.number <> 0 then err.clear
	else
		filethere = "no"
	end if

	if debug = 1 then screenout "  (Source File: " & bincheckfile & ")"
	if debug = 1 then screenout "  (Check File: " & filethere & ")"

	if datecomp(bincheckfile, filethere) and forceupdate = 0 then 
		screenout "  Localbin files OK."
	else
		REM #### Purge and replace localbin files ######
		screenout "  Removing the " & scriptbinvar & " directory..."
		if (Wshfile.folderexists(scriptbinvar)) then wshfile.deletefolder scriptbinvar, TRUE
		if err.number <> 0 then
			err.clear
			screenout "    Folder could not be removed."
		end if
		if checkfreespace(15) = 1 then
			screenout ""
			text = "There is not enough free space on the boot drive to install the localbin files!"
			screenout text
			screenout "Please free up at least 15 MB of disk space on the boot drive for the localbin files."
			genevent "E", "3", text
			file_localbin = 1
			exit function
		end if
		if not (Wshfile.folderexists(scriptbinvar)) then wshfile.createfolder(scriptbinvar)
		screenout "  Starting copy of files to " & scriptbinvar & "..."
		strcmdline = "cmd /c ""xcopy /cdefhkrvyz " & scriptbinlocvar & " " & scriptbinvar & "\"""
		if debug = 1 then screenout "    (" & strcmdline & ")"
		temp = wshshell.Run(strcmdline, 1, true)
		if temp <> 0 then 
			screenout ""
			text = "The script was unable to complete the localbin files copy to the " & scriptbinvar & " directory!"
			screenout text
			screenout "Make sure the directory or a file in the directory is not in use by an application."
			screenout "Do not close the Command Prompt window that is copying files."
			screenout "Try removing the localbin directory from the server and run the script again."
			genevent "E", "3", text
			file_localbin = 1
			exit function
		end if
	end if

	REM ###### Timesync.cmd to bin directory ######
	screenout "  Updating Timesync.cmd in " & scriptbinvar & "..."
	if (Wshfile.fileexists(scriptbinvar & "\timesync.cmd")) then wshfile.deletefile scriptbinvar & "\timesync.cmd", TRUE
	if err.number <> 0 then err.clear
	if not (Wshfile.fileexists(scriptbinvar & "\timesync.cmd")) then wshfile.copyfile scriptcmdlocvar & "\timesync.cmd", scriptbinvar & "\", TRUE
	if err.number <> 0 then logerror "Copying TimeSync.cmd", err.number : err.clear

	REM ###### ITGBackup.vbs to bin directory ######
	screenout "  Updating ITGBackup.vbs in " & scriptbinvar & "..."
	if (Wshfile.fileexists(scriptbinvar & "\ITGBackup.vbs")) then wshfile.deletefile scriptbinvar & "\ITGBackup.vbs", TRUE
	if err.number <> 0 then err.clear
	if not (Wshfile.fileexists(scriptbinvar & "\ITGBackup.vbs")) then wshfile.copyfile scriptcmdlocvar & "\ITGBackup.vbs", scriptbinvar & "\", TRUE
	if err.number <> 0 then logerror "Copying ITGBackup.vbs", err.number : err.clear

	REM ###### BackGround.cmd to bin directory ######
	screenout "  Updating BackGround.cmd in " & scriptbinvar & "..."
	if (Wshfile.fileexists(scriptbinvar & "\BackGround.cmd")) then wshfile.deletefile scriptbinvar & "\BackGround.cmd", TRUE
	if err.number <> 0 then err.clear
	if not (Wshfile.fileexists(scriptbinvar & "\BackGround.cmd")) then wshfile.copyfile scriptcmdlocvar & "\BackGround.cmd", scriptbinvar & "\", TRUE
	if err.number <> 0 then logerror "Copying BackGround.cmd", err.number : err.clear

	if err.number <> 0 then logerror "End of file_localbin Function", err.number : err.clear
	file_localbin = 0
End Function





REM #################################################################################################
REM ###                                       Exchange Files                                      ###
REM #################################################################################################
Function file_exchange()
	dim text
	on error resume next


	REM ###### create d:\ntdumps on exchange servers ######
	if not exchangevar = "" then
		screenout "Checking file changes for Exchange services..."
		if Instr(1, harddrives, "D:", 1) <> 0 then
			if not (Wshfile.folderexists("d:\ntdumps")) then
				screenout "  Creating D:\ntdumps directory..."
				wshfile.createfolder("d:\ntdumps")
				if err.number <> 0 then err.clear
			else
				screenout "  D:\ntdumps is all created."
			end if
			if not (Wshfile.folderexists("d:\exchsrvr")) then
				screenout "  Creating D:\exchsrvr directory..."
				wshfile.createfolder("d:\exchsrvr")
				if err.number <> 0 then err.clear
			else
				screenout "  D:\exchsrvr is all created."
			end if
		else
			screenout ""
			text = "Unable to create Exchange dump file directory as D: is not currently a valid hard drive!"
			screenout text
			screenout "Make sure that the D: drive is partitioned and formatted NTFS."
			genevent "E", "3", text
			file_localbin = 1
			exit function
		end if
	else
		screenout "File changes for Exchange services not needed."
	end if

	if err.number <> 0 then logerror "End of file_exchange Function", err.number : err.clear
	file_exchange = 0
End Function





REM #################################################################################################
REM ###                                       Boot.ini file                                       ###
REM #################################################################################################
Function file_boot()
	dim strcmdline, temp, text
	dim wshgetbootfile, attribute
	dim wshreadbootfile, wshnewbootfile, change, line, addon, newline, first, last
	dim wshgetnewbootfile
	on error resume next

	REM ###### Change Boot.ini file for the right architecture ######
	if procarc = "x86" then
		screenout "Checking i386 Boot.ini..."
		REM ###### Removes oldboot.ini file and set attributes so file can be read ######
		if (wshfile.fileexists(systemdrive & "\boot.ini")) then 
			set wshgetbootfile = wshfile.getfile(systemdrive & "\boot.ini")
			attribute = wshgetbootfile.attributes
			wshgetbootfile.attributes = 0
		else
			screenout "  Cannot find Boot.ini file!"
		end if

		REM ###### Open files, read, change if needed, close files #######
		if (wshfile.fileexists(systemdrive & "\boot.ini")) then 
			set wshreadbootfile = wshfile.OpenTextFile(systemdrive & "\boot.ini", 1)
			set wshnewbootfile = Wshfile.createtextfile(systemdrive & "\newboot.ini",1)
			change = 0
			addon = ""
			backuproot = ""
			Do While wshreadbootfile.AtEndOfStream <> true
				line = wshreadbootfile.ReadLine
				if Instr(1, line, "Microsoft Windows 2000 Advanced Server", 1) <> 0 then
					if Instr(1, line, "/sos", 1) = 0 then
						screenout "  Adding /sos..."
						change = 1
						addon = " /sos"
					end if
					if Instr(1, line, "/debug", 1) = 0 and not scriptsitevar = "DESK" then
						screenout "  Adding /debug..."
						change = 1
						addon = addon & " /debug"
					end if
					if Instr(1, line, "/baudrate=57600", 1) = 0 and not scriptsitevar = "DESK" then
						screenout "  Adding /baudrate=57600..."
						change = 1
						addon = addon & " /baudrate=57600"
					end if
					if Instr(1, line, "/debugport=com1", 1) = 0 and srvhardtypevar = "6400R" then
						screenout "  Adding /debugport=com1..."
						change = 1
						addon = addon & " /debugport=com1"
					end if
					wshnewbootfile.writeline(line & addon)
				elseif Instr(1, line, "timeout", 1) <> 0 then
					if Instr(1, line, "=10", 1) = 0 then
						screenout "  Changing timeout to 10 seconds..."
						change=1
						line = left(line,8) & "10"
					end if
					wshnewbootfile.writeline(line)
				elseif Instr(1, line, "backup", 1) <> 0 then
					screenout "  Removing Backup build entry..."
					change = 1
					first = Instr(1, line, "\", 1)
					last = Instr(1, line, "=", 1)
					backuproot = systemdrive & mid(line, first, last-first)
				elseif Instr(1, line, systemdrive & "\=", 1) <> 0 and srvbootvar = "NTFS" then
					screenout "  Removing MS-DOS or Microsoft Windows option..."
					change = 1
				else
					wshnewbootfile.writeline(line)
				end if
			Loop
			wshreadbootfile.close
			wshnewbootfile.close
			wscript.DisconnectObject wshreadbootfile
			wscript.DisconnectObject wshnewbootfile
			set wshreadbootfile=nothing
			set wshnewbootfile=nothing
		end if

		REM ###### if new file was changed then rename files, otherwise delete new file ######
		if change = 1 then
			screenout "  Changing to new boot.ini file..."
			if (wshfile.fileexists(systemdrive & "\oldboot.ini")) then wshfile.deletefile systemdrive & "\oldboot.ini", TRUE
			wshgetbootfile.name = "oldboot.ini"
			set wshgetnewbootfile = wshfile.getfile(systemdrive & "\newboot.ini")
			wshgetnewbootfile.name = "boot.ini"
			wshgetnewbootfile.attributes = attribute
			if err.number <> 0 then err.clear
		else
			screenout "  Boot.ini file OK."
			wshgetbootfile.attributes = attribute
			wshfile.deletefile systemdrive & "\newboot.ini", TRUE
			if err.number <> 0 then err.clear
		end if
		if not backuproot = "" then
			screenout "  (Backup build directory is " & backuproot & ".)"
		end if
	elseif srvarcvar = "alpha" then
		screenout "Changing Boot options for Alpha servers..."
		strCmdLine = "cmd /c """& scriptfileslocvar & "\nvram /set OSLOADOPTIONS = ""/sos /debug"""""
		temp = wshshell.Run(strcmdline, 0, true)
		strCmdLine = "cmd /c """& scriptfileslocvar & "\nvram /set COUNTDOWN = ""10"""""
		temp = wshshell.Run(strcmdline, 0, true)
	else
		screenout "Changes to the boot.ini for this architecture are not supported."
	end if

	if err.number <> 0 then logerror "End of file_boot Function", err.number : err.clear
	file_boot = 0
End Function




REM #################################################################################################
REM ###                                       Delete files                                        ###
REM #################################################################################################
Function file_delete()
	dim wshinifile, file, wshgettempfile
	on error resume next

	REM ###### Remove attributes of autoexec.bat and config.sys file ######
	if (wshfile.fileexists(systemdrive & "\autoexec.bat")) then 
		set wshgettempfile = wshfile.getfile(systemdrive & "\autoexec.bat")
		attribute = wshgettempfile.attributes
		wshgettempfile.attributes = 0
	end if
	if (wshfile.fileexists(systemdrive & "\config.sys")) then 
		set wshgettempfile = wshfile.getfile(systemdrive & "\config.sys")
		attribute = wshgettempfile.attributes
		wshgettempfile.attributes = 0
	end if
	if (Wshfile.FileExists(systemdrive & "\autoexec.bat")) then wshfile.deletefile systemdrive & "\autoexec.bat", TRUE
	if (Wshfile.FileExists(systemdrive & "\config.sys")) then wshfile.deletefile systemdrive & "\config.sys", TRUE

	REM ###### Remove install, promotion, and addon files ######
	if (Wshfile.FileExists(systemdrive & "\answer.txt")) then wshfile.deletefile systemdrive & "\answer.txt", TRUE
	if (Wshfile.FileExists(systemdrive & "\winnt.sif")) then wshfile.deletefile systemdrive & "\winnt.sif", TRUE
	if (Wshfile.FileExists(systemdrive & "\addon.inf")) then wshfile.deletefile systemdrive & "\addon.inf", TRUE
	if (Wshfile.FileExists(systemdrive & "\dcpromo-ntupg.inf")) then wshfile.deletefile systemdrive & "\dcpromo-ntupg.inf", TRUE
	if (Wshfile.FolderExists(systemdrive & "\ESP")) then wshfile.deletefolder systemdrive & "\ESP", TRUE
	if (Wshfile.FolderExists(systemroot & "\itg")) then wshfile.deletefolder systemroot & "\itg", TRUE
	if err.number <> 0 then err.clear


	REM ###### Delete Files ######	
	if (Wshfile.fileexists(scriptinilocvar & "\DeleteFilesW2K.ini")) then 
		Set wshinifile = wshfile.OpenTextFile(scriptinilocvar & "\DeleteFilesW2K.ini", 1)
		screenout "Deleting unwanted file(s)..."
		Do While wshinifile.AtEndOfStream <> true
			file = wshiniFile.ReadLine
			if (Wshfile.FileExists(file)) then wshfile.deletefile file, TRUE
			if err.number <> 0 then err.clear
		loop
		wshinifile.Close
	else
		screenout ""
		text = "The script was unable to find the DeleteFilesW2K.ini file!"
		screenout text
		screenout "Make sure that " & scriptinilocvar & " exists and contains the necessary INI file."
		genevent "E", "3", text
		file_delete = 1
		exit function
	end if

	wscript.DisconnectObject wshinifile
	set wshinifile=nothing

	if err.number <> 0 then logerror "End of file_delete Function", err.number : err.clear
	file_delete = 0
End Function




REM #################################################################################################
REM ###                                  Backgroup Bitmap File                                    ###
REM #################################################################################################
Function file_bitmap()
	dim strcmdline, temp, background
	on error resume next

	REM ### Check Background Bitmap stuff ###
	if argument("/nobitmap") <> 0 then
		screenout "Background bitmap changes have been disabled by the user."
	else
		screenout "Checking background bitmap settings..."
		background = WshShell.RegRead("HKEY_USERS\.default\Control Panel\desktop\wallpaper")
		if err.number <> 0 then logerror "Reading ITG background bitmap registry location", err.number : err.clear
		if cstr(background) = systemroot & "\ITGServerName.bmp" then
			screenout "  ITG background bitmap registry location OK."
		else
			screenout "  Setting ITG background bitmap registry location..."
			wshshell.regwrite "HKEY_USERS\.default\Control Panel\desktop\wallpaper", systemroot & "\ITGServerName.bmp", "REG_SZ"
			wshshell.regwrite "HKEY_USERS\.default\Control Panel\desktop\tilewallpaper", "1", "REG_SZ"
			if err.number <> 0 then logerror "Writing ITG background bitmap registry location", err.number : err.clear
			wshshell.regwrite "HKCU\Control Panel\desktop\wallpaper", "(None)", "REG_SZ"
			wshshell.regwrite "HKCU\Control Panel\desktop\tilewallpaper", "0", "REG_SZ"
			if err.number <> 0 then logerror "Clearing users background registry location", err.number : err.clear
			logregistryentry "ITG background bitmap registry location", "Updated", "HKEY_USERS\.default\Control Panel\desktop\wallpaper", systemroot & "\ITGServerName.bmp"
		end if
		if termvar = "TermRa" then
			screenout "  Setting ITG background bitmap registry location for TS-RA..."
			wshshell.regwrite "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp\UserOverride\Control Panel\desktop\wallpaper", systemroot & "\ITGServerName.bmp", "REG_SZ"
			wshshell.regwrite "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp\UserOverride\Control Panel\desktop\tilewallpaper", "0", "REG_SZ"
			if err.number <> 0 then logerror "Writing TS Background bitmap registry location", err.number : err.clear
		elseif termvar = "TermApp" then
			screenout "  Clearing ITG background bitmap registry location for TS-APP..."
			wshshell.regwrite "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp\UserOverride\Control Panel\desktop\wallpaper", "(None)", "REG_SZ"
			if err.number <> 0 then logerror "Clearing TS Background bitmap registry location", err.number : err.clear
		end if
		if (Wshfile.FileExists(scriptpathlocvar & "\bin\ITGSN.bmp")) then
			screenout "  Updating ITG background bitmap on server..."
			if (Wshfile.FileExists(systemroot & "\ITGSN.bmp")) then wshfile.deletefile systemroot & "\ITGSN.bmp"
			wshfile.copyfile scriptpathlocvar & "\bin\ITGSN.bmp", systemroot & "\ITGSN.bmp", TRUE
		else
			screenout "  Cannot find the source background bitmap at " & scriptpathlocvar & "\bin\ITGSN.bmp!"
		end if
		if (Wshfile.FileExists(systemroot & "\ITGSN.bmp")) then
			screenout "  Updating ITG background bitmap with the server name..."
			if (Wshfile.FileExists(systemroot & "\ITGServerName.bmp")) then wshfile.deletefile systemroot & "\ITGServerName.bmp"
			strcmdLine = "cmd /c """& scriptfileslocvar & "\bmpedit -m " & computername & " -v ""IPAK " & scriptipakvar & """ -r 255 -g 255 -b 255 -f1 28 -f2 12 -i " & systemroot & "\ITGSN.bmp -o " & systemroot & "\ITGServerName.bmp"""
			temp = wshshell.Run(strcmdline, 0, true)
		else
			screenout "  The source background bitmap did not get copied to the server!"
		end if
		if not (Wshfile.FileExists(systemroot & "\ITGServerName.bmp")) then
			screenout "  The source background bitmap did not get created on the server!"
		end if
	end if

	if err.number <> 0 then logerror "End of file_bitmap Function", err.number : err.clear
	file_bitmap = 0
End Function




REM #################################################################################################
REM ###                                      Registry                                             ###
REM #################################################################################################
Function registry(filetoprocess)
	dim text, wshinifile, space, rtext, rkey, rwhat, rvalue, rtype, temp, exists, correct
	on error resume next

	REM ###### Set Registry values ######	
	if (Wshfile.FileExists(filetoprocess)) then
		Set wshinifile = wshfile.OpenTextFile(filetoprocess, 1)
		if err.number <> 0 then logerror "Opening Registry INI file", err.number : err.clear
		Do While wshinifile.AtEndOfStream <> true
			space = wshiniFile.ReadLine
			rtext = wshinifile.readline
			rwhat = wshinifile.ReadLine
			rkey = wshiniFile.ReadLine
			rvalue = wshiniFile.ReadLine
			rtype = wshiniFile.ReadLine
			temp = WshShell.RegRead(rkey)
			if err.number = 0 then
				exists = 1
			else
				exists = 0
				if err.number <> 0 then err.clear
			end if
			if cstr(temp) = cstr(rvalue) then
				correct = 1
			else
				correct = 0
			end if
			if rwhat = "create" and exists = 0 then
				screenout "  Registry entry being created...  (" & rtext & ")"
				wshshell.regwrite rkey, rvalue, rtype
				logregistryentry rtext, "Created", rkey, rvalue
				if err.number <> 0 then logerror "Writing to registry", err.number : err.clear
			elseif rwhat = "update" and exists = 1 and correct = 0 then
				screenout "  Registry entry being corrected...  (" & rtext & ")"
				wshshell.regwrite rkey, rvalue, rtype
				logregistryentry rtext, "Corrected", rkey, rvalue
				if err.number <> 0 then logerror "Writing to registry", err.number : err.clear
			elseif rwhat = "set" and exists = 0 then
				screenout "  Registry entry being created...  (" & rtext & ")"
				wshshell.regwrite rkey, rvalue, rtype
				logregistryentry rtext, "Created", rkey, rvalue
				if err.number <> 0 then logerror "Writing to registry", err.number : err.clear
			elseif rwhat = "set" and exists = 1 and correct = 0 then
				screenout "  Registry entry being corrected...  (" & rtext & ")"
				wshshell.regwrite rkey, rvalue, rtype
				logregistryentry rtext, "Corrected", rkey, rvalue
				if err.number <> 0 then logerror "Writing to registry", err.number : err.clear
			elseif rwhat = "remove" and exists = 1 then
				screenout "  Registry entry being removed...  (" & rtext & ")"
				wshshell.regdelete rkey
				logregistryentry rtext, "Removed", rkey, rvalue
				if err.number <> 0 then logerror "Writing to registry", err.number : err.clear
			elseif rwhat = "" or not (rwhat = "create" or rwhat = "update" or rwhat = "set" or rwhat = "remove") then 
				screenout "  Invalid Command!  (" & rwhat & ")" 
			else
				screenout "  Registry entry OK.  (" & rtext & ")"
			end if
		Loop
		wshinifile.Close
		wscript.DisconnectObject wshinifile
		set wshinifile=nothing
	else
		screenout ""
		text = "The script was unable to find the " & filetoprocess & " file!"
		screenout text
		screenout "Make sure that the file is located in the above location."
		genevent "E", "3", text
		registry = 1
		exit function
	end if

	if err.number <> 0 then logerror "End of registry Function", err.number : err.clear
	registry = 0
End Function




REM #################################################################################################
REM ###                                  Registry backup                                          ###
REM #################################################################################################
Function registry_backup()
	dim strcmdline, temp, text, wshtempfile, line, number, timesync, backup
	on error resume next

	REM ###### Checks for registry backup AT jobs ######
	screenout "Checking registry backup at jobs:"
	strcmdline = "cmd /c ""at \\" & computername & " > " & scripttempvar & "\atjobstemp.txt"""	
	temp = wshshell.Run(strcmdline, 0, true)
	if (Wshfile.fileexists(scripttempvar & "\atjobstemp.txt")) then 
		Set wshtempfile = wshfile.OpenTextFile(scripttempvar & "\atjobstemp.txt", 1)
		backup=0
		Do While wshtempfile.AtEndOfStream <> true
			line = wshtempFile.ReadLine
			if Instr(1, line, "rdisk", 1) then
				number = mid(line, 9, 1)
				screenout "  Removing Rdisk AT job ID " & number & "..."
				strcmdline = "cmd /c ""at " & number & " /d"""	
				temp = wshshell.Run(strcmdline, 0, true)
			elseif Instr(1, line, "regbackup", 1) then
				number = mid(line, 9, 1)
				screenout "  Removing RegBackup AT job ID " & number & "..."
				strcmdline = "cmd /c ""at " & number & " /d"""	
				temp = wshshell.Run(strcmdline, 0, true)
			elseif Instr(1, line, "itgbackup", 1) then
				screenout "  AT job for ItgBackup OK."
				backup=1
			end if
		Loop
		wshtempfile.Close
		wscript.DisconnectObject wshtempfile
		Set wshtempfile=nothing
		if backup <> 1 then
			screenout "  Adding AT job for ITGBackup..."
			strcmdline = "cmd /c ""at \\" & computername & " 3:00 /EVERY:m,t,w,th,f,s,su " & scriptbinvar & "\ITGBackup.vbs"""	
			temp = wshshell.Run(strcmdline, 0, true)
		end if
	else
		screenout ""
		text = "Unable to create a text file in the temporary directory for the script!"
		screenout text
		screenout "Make sure that " & scripttempvar & " exists and is writable."
		screenout "Make sure that at.exe is available and working properly (at \\servername)."
		genevent "E", "3", text
		registry_backup = 1
		exit function
	end if

	if err.number <> 0 then logerror "End of registry_backup Function", err.number : err.clear
	registry_backup = 0
End Function



REM #################################################################################################
REM ###                                      Registry Main                                        ###
REM #################################################################################################
Function registry_main()
	dim text
	on error resume next

	REM ###### Set Registry values ######	
	screenout "Checking Main registry entries:"
	registry_main = registry(scriptinilocvar & "\MainRegistryW2K.ini")

	if err.number <> 0 then logerror "End of registry_main Function", err.number : err.clear
End Function


REM #################################################################################################
REM ###                                    Registry Filters                                       ###
REM #################################################################################################
Function registry_filters()
	dim temp, strcmdline, text, wshtempfile, alltext, line, pos, value, value1
	on error resume next

	REM ###### check for PASSFILT security filter ######
	screenout "Checking security filter list:"

	REM ###### Get Current Filters ######
	strCmdLine = "cmd /c """& scriptfileslocvar & "\reg query ""HKLM\system\currentcontrolset\Control\LSA"" /v ""Notification Packages"" >" & scripttempvar & "\passfilttemp.txt"""
	temp = wshshell.Run(strcmdline, 0, true)
	if err.number <> 0 then err.clear
	if (Wshfile.fileexists(scripttempvar & "\passfilttemp.txt")) then 
		Set wshtempfile = wshfile.OpenTextFile(scripttempvar & "\passfilttemp.txt", 1)
		if wshtempfile.AtEndOfStream = true then screenout "Reg.exe cannot get filter information!"
		Do While wshtempfile.AtEndOfStream <> true
			line = wshtempFile.ReadLine
			if Instr(1, line, "Notification Packages", 1) <> 0 and Instr(1, line, "PASSFILT", 1) <> 0 then
				screenout "  Removing PASSFILT from filter list..."
				Value1 = replace(line, "PASSFILT\0", "", 40, 1, 1)
				Value = replace(value1, "\0\0", "", 1, 1)
				strCmdLine = "cmd /c """& scriptfileslocvar & "\reg add ""HKLM\system\currentcontrolset\Control\LSA"" /v ""Notification Packages"" /t REG_MULTI_SZ /d " & value & " /f"""
				temp = wshshell.Run(strcmdline, 0, true)
				if err.number <> 0 then err.clear
				exit do
			elseif Instr(1, line, "Notification Packages", 1) <> 0 and Instr(1, line, "PASSFILT", 1) = 0 then
				screenout "  PASSFILT does not exist as a filter."
				exit do
			else
			end if	
		Loop
		wshtempfile.Close
		wscript.DisconnectObject wshtempfile
		Set wshtempfile=nothing
	else
		screenout ""
		text = "Unable to create a text file in the temporary directory for the script!"
		screenout text
		screenout "Make sure that " & scripttempvar & " exists and is writable."
		screenout "Make sure that reg.exe in " & scriptfileslocvar & " is working properly."
		genevent "E", "3", text
		registry_filters = 1
		exit function
	end if

	if err.number <> 0 then logerror "End of registry_filters Function", err.number : err.clear
	registry_filters = 0
End Function



REM #################################################################################################
REM ###                                   Registry PageFile                                       ###
REM #################################################################################################
Function registry_pagefile()
	dim text, temp, pfarray, strcmdline, wshtempfile, line, pos, pos2, pos3, size1, size2
	dim currentmemsize, currentpagedrive, currentpagemin, currentpagemax, correctpagedrive, correctpagemin, correctpagemax, wshpagefile, pagefilesize
	on error resume next

	REM ###### Check pagefile setting ######
	screenout "Checking servers pagefile setting:"

	REM ### Don't run on SAP servers ###
	if not sapvar = "" then
		screenout "  The Pagefile does not get modified on SAP servers."
		registry_pagefile = 0
		exit function
	end if

	REM ###### Get Current memory size ######
	currentmemsize = srvmemvar
	screenout "  Current Physical memory is " & currentmemsize & " MB."

	REM ###### Get Current pagefile size ######
	pfarray =  WshShell.RegRead("HKLM\system\currentcontrolset\Control\session manager\memory management\pagingfiles")
	pos = instr(1, pfarray(0), "\", 1)
	currentpagedrive = left(pfarray(0), pos-1)
	pos2 = instr(1, pfarray(0), " ", 1)
	pos3 = instr(pos2+1, pfarray(0), " ", 1)
	currentpagemin = cint(mid(pfarray(0), pos2, pos3-pos2))
	currentpagemax = cint(mid(pfarray(0), pos3, len(pfarray(0))+1-pos3))
	screenout "  Current Pagefile is " & currentpagedrive & "\pagefile.sys " & currentpagemin & " " & currentpagemax & " MB."
	
	REM ###### get correct pagefile settings ######
	if currentmemsize >=2048 then
		correctpagedrive = systemdrive
		correctpagemin = currentmemsize
		correctpagemax  = currentmemsize
	else
		correctpagedrive = systemdrive
		correctpagemin = currentmemsize * 1.5
		correctpagemax  = currentmemsize * 1.5
	end if
	if currentmemsize >4095 then
		correctpagemin = 4095
		correctpagemax  = 4095
	end if

	screenout "  Correct Pagefile is " & correctpagedrive & "\pagefile.sys " & correctpagemin & " " & correctpagemax & " MB."
	REM ###### Check for correct size ######
	if currentpagedrive = "" or currentpagemin = "" or currentpagemax = "" then
		screenout "  Pagefile setting not being set due to problem getting current pagefile settings!"
	elseif currentpagedrive = correctpagedrive and currentpagemin = correctpagemin and currentpagemax = correctpagemax then
		screenout "  Pagefile setting OK."
	elseif checkfreespace((correctpagemin-currentpagemin) + 50) = 1 then
		screenout "  Pagefile setting not being set due to lack of drive space!"
	elseif not currentpagedrive = correctpagedrive then
		screenout "  Pagefile setting not being set due to being on a different drive!"
	elseif checkfreespace((correctpagemin-currentpagemin) + 50) = 0 then
		pfarray(0) = correctpagedrive & "\pagefile.sys " & correctpagemin & " " & correctpagemax
		screenout "  Pagefile setting being set to " & pfarray(0) & "..."
		strCmdLine = "cmd /c """& scriptfileslocvar & "\reg add ""HKLM\system\currentcontrolset\Control\session manager\memory management"" /v ""pagingfiles"" /t REG_MULTI_SZ /d """ & pfarray(0) & """ /f"""
		temp = wshshell.Run(strcmdline, 0, true)
		if err.number <> 0 then err.clear
	else
		screenout "  Pagefile cannot be set with existing conditions!"
	end if

	if err.number <> 0 then logerror "End of registry_pagefile Function", err.number : err.clear
	registry_pagefile = 0
End Function




REM #################################################################################################
REM ###                                     Registry Path                                         ###
REM #################################################################################################
Function registry_path()
	dim check, oldpath, newpath, firstpos, lastpos, onepart
	on error resume next

	REM ###### Get current path ######
	check = 0
	screenout "Checking machines Path:"
	oldpath = WshShell.Regread("HKLM\system\currentcontrolset\control\session manager\environment\path")
	if err.number <> 0 then err.clear
	screenout "  Old Path - " & oldpath
	newpath = "%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SystemDrive%\localbin"

	REM ###### Get each part of the current path and append it to the new path if needed ######
	screenout "  Creating new path..."
	firstpos = 1
	do
		lastpos = Instr(firstpos, oldpath, ";", 1)
		if lastpos = 0 then lastpos = len(oldpath) + 1
		onepart = mid(oldpath, firstpos, lastpos-firstpos)
		if check = 1 then screenout "    One part - " & onepart
		if check = 1 then screenout "      First Position - " & firstpos
		if check = 1 then screenout "      Last Position - " & lastpos
		if onepart = "" then
			if check = 1 then screenout "      Skipping 1... "
		elseif onepart = "c:\winnt" then
			if check = 1 then screenout "      Skipping 2... "
		elseif onepart = systemroot then
			if check = 1 then screenout "      Skipping 3... "
		elseif onepart = "%systemroot%" then
			if check = 1 then screenout "      Skipping 4... "
		elseif onepart = "%SystemRoot%" then
			if check = 1 then screenout "      Skipping 5... "
		elseif onepart = "c:\winnt\system32" then
			if check = 1 then screenout "      Skipping 6... "
		elseif onepart = systemroot & "\system32" then
			if check = 1 then screenout "      Skipping 7... "
		elseif onepart = "%systemroot%\system32" then
			if check = 1 then screenout "      Skipping 8... "
		elseif onepart = "%SystemRoot%\system32" then
			if check = 1 then screenout "      Skipping 9... "
		elseif onepart = "c:\winnt\system32\wbem" then
			if check = 1 then screenout "      Skipping 10... "
		elseif onepart = systemroot & "\System32\Wbem" then
			if check = 1 then screenout "      Skipping 11... "
		elseif onepart = "%systemroot%\System32\Wbem" then
			if check = 1 then screenout "      Skipping 12... "
		elseif onepart = "%SystemRoot%\System32\Wbem" then
			if check = 1 then screenout "      Skipping 13... "
		elseif onepart = "%SystemRoot%\system32\Wbem" then
			if check = 1 then screenout "      Skipping 14... "
		elseif onepart = "%SystemRoot%\system32\WBEM" then
			if check = 1 then screenout "      Skipping 25... "
		elseif onepart = "c:\localbin" then
			if check = 1 then screenout "      Skipping 15... "
		elseif onepart = "%systemdrive%\localbin" then
			if check = 1 then screenout "      Skipping 16... "
		elseif onepart = "%SystemDrive%\localbin" then
			if check = 1 then screenout "      Skipping 17... "
		elseif onepart = systemdrive & "\localbin" then
			if check = 1 then screenout "      Skipping 18... "
		elseif onepart = "C:\Program" then
			if check = 1 then screenout "      Skipping 19... "
		elseif onepart = "C:\PROGRA~1\Dell\bin" then
			if check = 1 then screenout "      Skipping 20... "
		elseif onepart = "C:\PROGRA~1\Dell\ihv\bin" then
			if check = 1 then screenout "      Skipping 21... "
		elseif onepart = "C:\PROGRA~1\Dell\dmi\bin" then
			if check = 1 then screenout "      Skipping 22... "
		elseif onepart = "C:\Program Files\PERC2\System" then
			if check = 1 then screenout "      Skipping 23... "
		elseif onepart = "c:\localbin\dos" then
			if check = 1 then screenout "      Skipping 24... "
		elseif onepart = "c:\" then
		else
			screenout "      Appending " & onepart & " to the new path..."
			newpath = newpath & ";" & onepart
		end if
		firstpos = lastpos + 1
	loop while not lastpos = len(oldpath) + 1
	screenout "  New Path - " & newpath

	REM ### Add new path to machine if it has changed ###
	if newpath = oldpath or check = 1 then
		screenout "  Machine path OK."
	else
		screenout "  Correcting machines path..."
		wshshell.regwrite "HKLM\system\currentcontrolset\control\session manager\environment\path", newpath, "REG_EXPAND_SZ"
		if err.number <> 0 then logerror "Setting Machine Path", err.number : err.clear
		logregistryentry "System Path", "Corrected", "HKLM\system\currentcontrolset\control\session manager\environment\path", newpath
	end if

	if err.number <> 0 then logerror "End of registry_path Function", err.number : err.clear
	registry_path = 0
End Function




REM #################################################################################################
REM ###                                  Registry Source location                                 ###
REM #################################################################################################
Function registry_source()
	dim source1, source2, source3, text
	on error resume next

	if bldvar = "off" or bldvar = "switch" then
	else
		REM ###### Checking default source path ######
		screenout "Checking machines default source path(s):"

		REM ###### Get path and check ######
		source1 = WshShell.RegRead("HKLM\software\microsoft\windows nt\currentversion\SourcePath")
		source2 = WshShell.RegRead("HKLM\software\microsoft\windows\currentversion\setup\SourcePath")
		source3 = WshShell.RegRead("HKLM\software\microsoft\windows\currentversion\setup\ServicePackSourcePath")
		if err.number <> 0 then logerror "Reading first sourcepath", err.number : err.clear
		if cstr(source1) = cstr(bldlocvar) and cstr(source2) = cstr(bldlocvar) and cstr(source3) = cstr(splocvar) then
			screenout "  Default source path registry locations OK."
		else
			screenout "  Setting default source path registry locations..."
			wshshell.regwrite "HKLM\software\microsoft\windows nt\currentversion\SourcePath", bldlocvar, "REG_SZ"
			wshshell.regwrite "HKLM\software\microsoft\windows\currentversion\setup\SourcePath", bldlocvar, "REG_SZ"
			wshshell.regwrite "HKLM\software\microsoft\windows\currentversion\setup\ServicePackSourcePath", splocvar, "REG_SZ"
			if err.number <> 0 then logerror "Default source path registry locations", err.number : err.clear
			logregistryentry "Source Files", "Updated", "HKLM\software\microsoft\windows nt\currentversion\SourcePath", bldlocvar
			logregistryentry "Source Files 2", "Updated", "HKLM\software\microsoft\windows\currentversion\setup\SourcePath", bldlocvar
			logregistryentry "Source Files 3", "Updated", "HKLM\software\microsoft\windows\currentversion\setup\ServicePackSourcePath", splocvar
		end if
	end if

	if err.number <> 0 then logerror "End of registry_source Function", err.number : err.clear
	registry_source = 0
End Function




REM #################################################################################################
REM ###                                  Registry DiskPerf settings                               ###
REM #################################################################################################
Function registry_diskperf()
	dim strcmdline, temp, text
	on error resume next

	REM ###### Registering DiskPerf counters ######
	screenout "Checking disk perfmon counters:"

	REM ###### Registering DiskPerf counters ######
	screenout "  Disabling disk perfmon counters..."
	strcmdline = "cmd /c ""diskperf -N"""
        temp = wshshell.Run(strcmdline, 0, TRUE)
        if err.number <> 0 then err.clear
	screenout "  Enabling disk perfmon counters..."
	strcmdline = "cmd /c ""diskperf -Y"""
        temp = wshshell.Run(strcmdline, 0, TRUE)
        if err.number <> 0 then err.clear

	if err.number <> 0 then logerror "End of registry_diskperf Function", err.number : err.clear
	registry_diskperf = 0
End Function




REM #################################################################################################
REM ###                                      Registry Site                                        ###
REM #################################################################################################
Function registry_site()
	dim text, siteregistryfile
	on error resume next

	Select Case scriptconswivar
		Case "/b11-corp": siteregistryfile = "b11corp"
		Case "/b11-int": siteregistryfile = "cpint"
		Case "/b11-ext": siteregistryfile = "cpint"
		Case "/cp-corp": siteregistryfile = "b11corp"
		Case "/cp-int": siteregistryfile = "cpint"
		Case "/cp-ext": siteregistryfile = "cpint"
		Case "/tuk-corp": siteregistryfile = "b11corp"
		Case "/tuk-int": siteregistryfile = "cpint"
		Case "/tuk-ext": siteregistryfile = "cpint"
		Case "/sat-corp": siteregistryfile = "satcorp"
		Case "/sat-int": siteregistryfile = "satint"
		Case "/sat-ext": siteregistryfile = "satint"
		Case "/jup-corp": siteregistryfile = "jupcorp"
		Case "/jup-int": siteregistryfile = "jupcorp"
		Case "/jup-ext": siteregistryfile = "jupcorp"
		Case "/soc-corp": siteregistryfile = "socint"
		Case "/soc-int": siteregistryfile = "socint"
		Case "/soc-ext": siteregistryfile = "socint"
		Case "/dsk-corp": siteregistryfile = "deskcorp"
		Case "/dsk-int": siteregistryfile = "deskcorp"
		Case "/dsk-ext": siteregistryfile = "deskcorp"
		Case "/noam-corp": siteregistryfile = "noamcorp"
		Case "/noam-int": siteregistryfile = "noamint"
		Case "/noam-ext": siteregistryfile = "noamint"
		Case "/soam-corp": siteregistryfile = "noamcorp"
		Case "/soam-int": siteregistryfile = "noamint"
		Case "/soam-ext": siteregistryfile = "noamint"
		Case "/sopa-corp": siteregistryfile = "faeacorp"
		Case "/sopa-int": siteregistryfile = "faeaint"
		Case "/sopa-ext": siteregistryfile = "faeaint"
		Case "/faea-corp": siteregistryfile = "faeacorp"
		Case "/faea-int": siteregistryfile = "faeaint"
		Case "/faea-ext": siteregistryfile = "faeaint"
		Case "/euro-corp": siteregistryfile = "eurocorp"
		Case "/euro-int": siteregistryfile = "euroint"
		Case "/euro-ext": siteregistryfile = "euroint"
		Case "/miea-corp": siteregistryfile = "eurocorp"
		Case "/miea-int": siteregistryfile = "euroint"
		Case "/miea-ext": siteregistryfile = "euroint"
		Case "/afca-corp": siteregistryfile = "eurocorp"
		Case "/afca-int": siteregistryfile = "euroint"
		Case "/afca-ext": siteregistryfile = "euroint"
		Case else
			screenout "No registry configuration exists for '" & scriptconswivar & "'!"
			registry_site = 0
			exit function
	End Select
	REM ###### Set Site Registry values ######
	screenout "Checking registry entries for " & siteregistryfile & " configuration:"
	registry_site = registry(scriptinilocvar & "\config\" & siteregistryfile & "RegistryW2K.ini")
	if registry_site = 1 then exit function

	if err.number <> 0 then logerror "End of registry_site Function", err.number : err.clear
	registry_site = 0
End Function



REM #################################################################################################
REM ###                                      Registry Debug                                        ###
REM #################################################################################################
Function registry_debug()
	dim text
	on error resume next

	REM ###### Set memory dump settings ######	
	screenout "Checking memory dump setting:"
	if srvmemvar <= 2048 then
		registry_debug = registry(scriptinilocvar & "\DumpComRegistryW2K.ini")
		if registry_debug = 1 then exit function
	else
		registry_debug = registry(scriptinilocvar & "\DumpKernRegistryW2K.ini")
		if registry_debug = 1 then exit function
	end if

	REM ###### Set full debug settings ######
	if srvdebug = 1 then
		screenout "Checking full debugger settings:"
		registry_debug = registry(scriptinilocvar & "\FullDebugRegistryW2K.ini")
		if registry_debug = 1 then exit function
	end if

	REM ###### Set DC Debug/registry Settings ######
	if srvrolevar = "Domain Controller" then
		screenout "Checking DC Registry Settings:"
		registry_debug = registry(scriptinilocvar & "\DCRegistryW2K.ini")
		if registry_debug = 1 then exit function
	end if

	if err.number <> 0 then logerror "End of registry_debug Function", err.number : err.clear
	registry_debug = 0
End Function



REM #################################################################################################
REM ###                                  Registry Services                                        ###
REM #################################################################################################
Function registry_services()
	dim text
	on error resume next

	REM #### Set optimization to Network Application for given services ######
	if not wwwvar = "" or not sqlvar = "" or not exchangevar = "" or not sapvar = "" then
		screenout "Checking registry entries for Optimization:"
		registry_services = registry(scriptinilocvar & "\OPTORegistryW2K.ini")
		if registry_services = 1 then exit function
	end if

	REM ###### Set TSRA Registry values ######
	if termvar = "TermRa" and (Wshfile.FileExists(scriptinilocvar & "\TermRaRegistryW2K.ini")) then
		screenout "Checking registry entries for Terminal Service (Remote Administration):"
		registry_services = registry(scriptinilocvar & "\TermRaRegistryW2K.ini")
		if registry_services = 1 then exit function
	elseif termvar = "TermApp" and (Wshfile.FileExists(scriptinilocvar & "\TermAppRegistryW2K.ini")) then
		screenout "Checking registry entries for Terminal Service (Application):"
		registry_services = registry(scriptinilocvar & "\TermAppRegistryW2K.ini")
		if registry_services = 1 then exit function
	end if

	REM #### Set registry settings on WWW servers ######
	if not wwwvar = "" and (Wshfile.FileExists(scriptinilocvar & "\WWWRegistryW2K.ini")) then
		screenout "Checking registry entries for WWW services:"
		registry_services = registry(scriptinilocvar & "\WWWRegistryW2K.ini")
		if registry_services = 1 then exit function
	end if

	REM #### Set registry settings on SQL servers ######
	if not sqlvar = "" and (Wshfile.FileExists(scriptinilocvar & "\SQLRegistryW2K.ini")) then
		screenout "Checking registry entries for SQL services:"
		registry_services = registry(scriptinilocvar & "\SQLRegistryW2K.ini")
		if registry_services = 1 then exit function
	end if

	REM #### Set registry settings on exchange servers ######
	if not exchangevar = "" and (Wshfile.FileExists(scriptinilocvar & "\EXCRegistryW2K.ini"))then
		screenout "Checking registry entries for Exchange services:"
		registry_services = registry(scriptinilocvar & "\EXCRegistryW2K.ini")
		if registry_services = 1 then exit function
	end if

	REM #### Set registry settings on sap servers ######
	if not sapvar = "" and (Wshfile.FileExists(scriptinilocvar & "\SAPRegistryW2K.ini")) then
		screenout "Checking registry entries for SAP services:"
		registry_services = registry(scriptinilocvar & "\SAPRegistryW2K.ini")
		if registry_services = 1 then exit function
	end if

	if err.number <> 0 then logerror "End of registry_services Function", err.number : err.clear
	registry_services = 0
End Function




REM #################################################################################################
REM ###                                    Perfcol                                                ###
REM #################################################################################################
Function tools_perfcol()
	dim temp, strcmdline, text
	on error resume next

	REM ### Add Perfcol group for perfmon access ###
	screenout "Adding Perfcol group to registry permissions for perfcol counter access..."
	strCmdLine = "cmd /c """& scriptfileslocvar & "\regsecadd -l -a ""software\microsoft\windows nt\currentversion\perflib"" Redmond\Perfcol"""
	temp = wshshell.Run(strcmdline, 0, true)
	if err.number <> 0 then err.clear
	strCmdLine = "cmd /c """& scriptfileslocvar & "\regsecadd -l -a ""system\currentcontrolset\control\securepipeservers\winreg"" Redmond\Perfcol"""
	temp = wshshell.Run(strcmdline, 0, true)
	if err.number <> 0 then err.clear
	strCmdLine = "cmd /c """& scriptfileslocvar & "\regsecadd -l -a ""system\currentcontrolset\control\securepipeservers\winreg\allowedpaths"" Redmond\Perfcol"""
 	temp = wshshell.Run(strcmdline, 0, true)
	if err.number <> 0 then err.clear
	strCmdLine = "cmd /c """& scriptfileslocvar & "\regsecadd -l -a ""software\microsoft\windows nt\currentversion\perflib"" Houston\Perfcol"""
	temp = wshshell.Run(strcmdline, 0, true)
	if err.number <> 0 then err.clear
	strCmdLine = "cmd /c """& scriptfileslocvar & "\regsecadd -l -a ""system\currentcontrolset\control\securepipeservers\winreg"" Houston\Perfcol"""
	temp = wshshell.Run(strcmdline, 0, true)
	if err.number <> 0 then err.clear
	strCmdLine = "cmd /c """& scriptfileslocvar & "\regsecadd -l -a ""system\currentcontrolset\control\securepipeservers\winreg\allowedpaths"" Houston\Perfcol"""
 	temp = wshshell.Run(strcmdline, 0, true)
	if err.number <> 0 then err.clear
	if temp <> 0 then
		screenout "  Failed to properly add Perfcol group(s) to registy!" 
	end if

	if err.number <> 0 then logerror "End of tools_perfcol Function", err.number : err.clear
	tools_perfcol = 0
End Function




REM #################################################################################################
REM ###                                            OIC                                            ###
REM #################################################################################################
Function tools_oic()
	dim temp, strcmdline, text, regthere, filethere, servfile, lettervar, locationvar, reboot, inocsitevar
	on error resume next

	REM ### Check for Object Inactivity Checker location ###
	screenout "Object Inactivity Checker:"
	if oicvar = "off"  then
		screenout "  Object Inactivity Checker install is disabled."
		oiclogvar = "Disabled"
		oiclogvar = "Did Not Run Correctly"
	elseif oicvar = "switch"  then
		screenout "  Object Inactivity Checker install has been turned off by the user."
		oiclogvar = "Disabled - By User"
	elseif not srvrolevar = "Domain Controller" then
		screenout "  Object Inactivity Checker install is not needed on Servers (DC's Only!)."
		oiclogvar = "Not a Domain Controller"
	else	
		if (Wshfile.fileexists(oicchkvar)) then
			set servfile = Wshfile.getfile(oicchkvar)
			filethere = datevalue(left(servfile.datelastmodified, Instr(1, servfile.datelastmodified, " ", 1)-1))
			wscript.DisconnectObject servfile
			set servfile=nothing
			if err.number <> 0 then err.clear
		else
			filethere = "no"
		end if
		oicfilevar = datevalue(oicfilevar)

		if debug = 1 then screenout "  (Object Inactivity Checker File - " & filethere & ")"

		if datecomp(oicfilevar, filethere) and forceupdate = 1 then 
			screenout "  Updating Object Inactivity Checker..."
			oiclogvar = "Updated"
		elseif datecomp(oicfilevar, filethere) then 
			screenout "  Object Inactivity Checker OK."
			oiclogvar = "OK"
			tools_oic = 0
			exit function
		elseif filethere = "no" then 
			screenout "  Installing Object Inactivity Checker..."
			oiclogvar = "Installed"
		else
			screenout "  Upgrading Object Inactivity Checker..."
			oiclogvar = "Upgraded"
		end if
		if (Wshfile.FileExists(oiclocvar)) and checkfreespace(5) = 0 then
			strcmdline = "cmd /c """ & oiclocvar & """"
			if debug = 1 then screenout "  (" & strcmdline & ")"
			temp = wshshell.Run(strcmdline, 1, true)
		elseif checkfreespace(5) = 1 then
			text = "  There is not enough free space on the boot drive to install OIC!"
			screenout text
			genevent "W", "4", text
			oiclogvar = "Not Enough Disk Space"
		else
			text = "  The script could not locate the OIC install script!"
			screenout text
			screenout "  (" & oiclocvar & ")"
			genevent "W", "4", text
			oiclogvar = "No Install File"
		end if
	end if


	if err.number <> 0 then logerror "End of tools_oic Function", err.number : err.clear
	tools_oic = 0
End Function




REM #################################################################################################
REM ###                                           Opassist                                        ###
REM #################################################################################################
Function tools_opassist()
	dim temp, strcmdline, servfile, filethere, text
	on error resume next

	REM ### Check for opassist location ###
	screenout "OpAssist:"
	if opavar = "off"  then
		screenout "  OpAssist install is disabled."
		opalogvar = "Disabled"
	elseif scriptsitevar = "DESK" then
		screenout "  Opassist is not needed on a Desktop configuration."
		opalogvar = "Desktop configuration."
	elseif opavar = "switch"  then
		screenout "  OpAssist install has been turned off by the user."
		opalogvar = "Disabled - By User"
	else
		if (Wshfile.fileexists(opachkvar)) then
			set servfile = Wshfile.getfile(opachkvar)
			filethere = datevalue(left(servfile.datelastmodified, Instr(1, servfile.datelastmodified, " ", 1)-1))
			wscript.DisconnectObject servfile
			set servfile=nothing
			if err.number <> 0 then err.clear
		else
			filethere = "no"
		end if
		opafilevar = datevalue(opafilevar)

		if debug = 1 then screenout "  (OpAssist File: " & filethere & ")"

		if datecomp(opafilevar, filethere) and forceupdate = 1  then 
			screenout "  Updating OpAssist..."
			opalogvar = "Updated"
		elseif datecomp(opafilevar, filethere) then 
			screenout "  OpAssist OK."
			opalogvar = "OK"
			tools_opassist = 0
			exit function
		elseif filethere = "no" then 
			screenout "  Installing OpAssist..."
			opalogvar = "Installed"
		else
			screenout "  Upgrading OpAssist..."
			opalogvar = "Upgraded"
		end if
		if (Wshfile.FileExists(opalocvar)) and checkfreespace(10) = 0 then
			strcmdline = "cmd /c """ & opalocvar & """"
			if debug = 1 then screenout "  (" & strcmdline & ")"
			temp = wshshell.Run(strcmdline, 1, true)
		elseif checkfreespace(10) = 1 then
			text = "  There is not enough free space on the boot drive to install OpAssist!"
			screenout text
			genevent "W", "4", text
			opalogvar = "Not Enough Disk Space"
		else
			text = "  The script could not locate the OpAssist install script!"
			screenout text
			screenout "  (" & opalocvar & ")"
			genevent "W", "4", text
			opalogvar = "No Install File"
		end if
	end if


	if err.number <> 0 then logerror "End of tools_opassist Function", err.number : err.clear
	tools_opassist = 0
End Function




REM #################################################################################################
REM ###                                           Sentry                                          ###
REM #################################################################################################
Function tools_sentry()
	dim temp, strcmdline, text, regthere, filethere, servfile
	on error resume next

	REM ### Check for Sentry location ###
	screenout "Sentry:"
	if senvar = "off"  then
		screenout "  Sentry install is disabled."
		senlogvar = "Disabled"
	elseif scriptsitevar = "DESK" then
		screenout "  Sentry is not needed on a Desktop configuration."
		senlogvar = "Desktop configuration."
	elseif senvar = "switch"  then
		screenout "  Sentry install has been turned off by the user."
		senlogvar = "Disabled - By User"
	else
		if (Wshfile.fileexists(senchkvar)) then
			set servfile = Wshfile.getfile(senchkvar)
			filethere = datevalue(left(servfile.datelastmodified, Instr(1, servfile.datelastmodified, " ", 1)-1))
			wscript.DisconnectObject servfile
			set servfile=nothing
			if err.number <> 0 then err.clear
		else
			filethere = "no"
		end if
		senfilevar = datevalue(senfilevar)

		if debug = 1 then screenout "  (Current Sentry File: " & filethere & ")"

		if datecomp(senfilevar, filethere) and forceupdate = 1  then 
			screenout "  Updating Sentry..."
			senlogvar = "Updated"
		elseif datecomp(senfilevar, filethere) then 
			screenout "  Sentry OK."
			senlogvar = "OK"
			tools_sentry = 0
			exit function
		elseif filethere = "no" then 
			screenout "  Installing Sentry..."
			senlogvar = "Installed"
		else
			screenout "  Upgrading Sentry..."
			senlogvar = "Upgraded"
		end if
		if (Wshfile.FileExists(senlocvar)) and checkfreespace(25) = 0 then
			strcmdline = "cmd /c """ & senlocvar & " " & scriptconswivar & """"
			if debug = 1 then screenout "  (" & strcmdline & ")"
			temp = wshshell.Run(strcmdline, 1, true)
		elseif checkfreespace(25) = 1 then
			text = "  There is not enough free space on the boot drive to install Sentry!"
			screenout text
			genevent "W", "4", text
			senlogvar = "Not Enough Disk Space"
		else
			text = "  The script could not locate the Sentry install script!"
			screenout text
			screenout "  (" & senlocvar & ")"
			genevent "W", "4", text
			senlogvar = "No Install File"
		end if
	end if


	if err.number <> 0 then logerror "End of tools_Sentry Function", err.number : err.clear
	tools_Sentry = 0
End Function




REM #################################################################################################
REM ###                                        NetIQ                                           ###
REM #################################################################################################
Function tools_netiq()
	dim temp, strcmdline, text, regthere, filethere, servfile
	on error resume next

	REM ### Check for NetIQ location ###
	screenout "NetIQ:"
	if niqvar = "off"  then
		screenout "  NetIQ install is disabled."
		niqlogvar = "Disabled"
	elseif scriptsitevar = "DESK" then
		screenout "  NetIQ is not needed on a Desktop configuration."
		niqlogvar = "Desktop configuration."
	elseif niqvar = "switch"  then
		screenout "  NetIQ install has been turned off by the user."
		niqlogvar = "Disabled - By User"
	else	
		if (Wshfile.fileexists(niqchkvar)) then
			set servfile = Wshfile.getfile(niqchkvar)
			filethere = datevalue(left(servfile.datelastmodified, Instr(1, servfile.datelastmodified, " ", 1)-1))
			wscript.DisconnectObject servfile
			set servfile=nothing
			if err.number <> 0 then err.clear
		else
			filethere = "no"
		end if
		niqfilevar = datevalue(niqfilevar)

		if debug = 1 then screenout "  (NetIQ File: " & filethere & ")"

		if datecomp(niqfilevar, filethere) and forceupdate = 1  then 
			screenout "  Updating NetIQ..."
			niqlogvar = "Updated"
		elseif datecomp(niqfilevar, filethere) then 
			screenout "  NetIQ OK."
			niqlogvar = "OK"
			tools_netiq = 0
			exit function
		elseif filethere = "no" then 
			screenout "  Installing NetIQ..."
			niqlogvar = "Installed"
		else
			screenout "  Upgrading NetIQ..."
			niqlogvar = "Upgraded"
		end if
		if (Wshfile.FileExists(niqlocvar)) and checkfreespace(25) = 0 then
			strcmdline = "cmd /c """ & niqlocvar & " " & scriptconswivar & """"
			if debug = 1 then screenout "  (" & strcmdline & ")"
			temp = wshshell.Run(strcmdline, 1, true)
		elseif checkfreespace(25) = 1 then
			text = "  There is not enough free space on the boot drive to install NetIQ!"
			screenout text
			genevent "W", "4", text
			niqlogvar = "Not Enough Disk Space"
		else
			text = "  The script could not locate the NetIQ install script!"
			screenout text
			screenout "  (" & niqlocvar & ")"
			genevent "W", "4", text
			niqlogvar = "No Install File"
		end if
	end if


	if err.number <> 0 then logerror "End of tools_netiq Function", err.number : err.clear
	tools_netiq = 0
End Function




REM #################################################################################################
REM ###                                        Inoculan                                           ###
REM #################################################################################################
Function tools_inoculan()
	dim temp, strcmdline, text, regthere, filethere, servfile
	on error resume next

	REM ### Check for Inoculan location ###
	screenout "Inoculan:"
	if inocvar = "off"  then
		screenout "  Inoculan install is disabled."
		inoclogvar = "Disabled"
		inoclogvar = "Did Not Run Correctly"
	elseif inocvar = "switch"  then
		screenout "  Inoculan install has been turned off by the user."
		inoclogvar = "Disabled - By User"
	else	
		if (Wshfile.fileexists(inocchkvar)) then
			set servfile = Wshfile.getfile(inocchkvar)
			filethere = datevalue(left(servfile.datelastmodified, Instr(1, servfile.datelastmodified, " ", 1)-1))
			wscript.DisconnectObject servfile
			set servfile=nothing
			if err.number <> 0 then err.clear
		else
			filethere = "no"
		end if
		inocchkvar = datevalue(inocchkvar)

		if debug = 1 then screenout "  (Current Inoculan File - " & filethere & ")"

		if filethere = "no" and scriptsitevar = "DESK" then 
			screenout "  Installing Inoculan on this Desk top machine..."
			inoclogvar = "Installed - Desk Top"
		elseif filethere = "no" and not argument("/inocon") <> 0 then 
			screenout "  Inoculan is not enabled to install (Add the '/inocon' switch to enable)."
			inoclogvar = "Not Enabled"
			tools_inoculan = 0
			exit function
		elseif datecomp(inocfilevar, filethere) and forceupdate = 1 then 
			screenout "  Updating Inoculan..."
			inoclogvar = "Updated"
		elseif datecomp(inocfilevar, filethere) then 
			screenout "  Inoculan OK."
			inoclogvar = "OK"
			tools_inoculan = 0
			exit function
		elseif filethere = "no" and argument("/inocon") <> 0 then 
			screenout "  Installing Inoculan on this server..."
			inoclogvar = "Installed"
		else
			screenout "  Upgrading Inoculan..."
			inoclogvar = "Upgraded"
		end if
		if (Wshfile.FileExists(inoclocvar)) and checkfreespace(25) = 0 then
			strcmdline = "cmd /c """ & inoclocvar & " " & scriptconswivar & """"
			if debug = 1 then screenout "  (" & strcmdline & ")"
			temp = wshshell.Run(strcmdline, 1, true)
			screenout "    Clearing Inoculan for Windows NT window..."
			winmanipulate "", "Inoculan for Windows NT", "%fc"
			screenout "    Clearing Startup window..."
			winmanipulate "", "Startup", "%fc"
		elseif checkfreespace(25) = 1 then
			text = "  There is not enough free space on the boot drive to install Inoculan!"
			screenout text
			genevent "W", "4", text
			inoclogvar = "Not Enough Disk Space"
		else
			text = "  The script could not locate the Inoculan install script!"
			screenout text
			screenout "  (" & inoclocvar & ")"
			genevent "W", "4", text
			inoclogvar = "No Install File"
		end if
	end if

	if err.number <> 0 then logerror "End of tools_inoculan Function", err.number : err.clear
	tools_inoculan = 0
End Function




REM #################################################################################################
REM ###                                   Backup Accelerator                                      ###
REM #################################################################################################
Function tools_backupexec()
	dim temp, strcmdline, text, regthere, filethere, servfile
	on error resume next

	REM ### Check for Backup Accelerator location ###
	screenout "Backup Accelerator:"
	if bacvar = "off"  then
		screenout "  Backup Accelerator install is disabled."
		baclogvar = "Disabled"
		baclogvar = "Did Not Run Correctly"
	elseif bacvar = "switch"  then
		screenout "  Backup Accelerator install has been turned off by the user."
		baclogvar = "Disabled - By User"
	else	
		if (Wshfile.fileexists(bacchkvar)) then
			set servfile = Wshfile.getfile(bacchkvar)
			filethere = datevalue(left(servfile.datelastmodified, Instr(1, servfile.datelastmodified, " ", 1)-1))
			wscript.DisconnectObject servfile
			set servfile=nothing
			if err.number <> 0 then err.clear
		else
			filethere = "no"
		end if
		bacchkvar = datevalue(bacchkvar)

		if debug = 1 then screenout "  (Current Backup Accelerator File - " & filethere & ")"

		if filethere = "no" and not argument("/buacon") <> 0 then 
			screenout "  Backup Accelerator is not enabled to install (Add the '/buacon' switch to enable)."
			baclogvar = "Not Enabled"
			tools_backupexec = 0
			exit function
		elseif datecomp(bacfilevar, filethere) and forceupdate = 1 then 
			screenout "  Updating Backup Accelerator..."
			baclogvar = "Updated"
		elseif datecomp(bacfilevar, filethere) then 
			screenout "  Backup Accelerator OK."
			baclogvar = "OK"
			tools_backupexec = 0
			exit function
		elseif filethere = "no" and argument("/buacon") <> 0 then 
			screenout "  Installing Backup Accelerator on this server..."
			baclogvar = "Installed"
		else
			screenout "  Upgrading Backup Accelerator..."
			baclogvar = "Upgraded"
		end if
		if (Wshfile.FileExists(baclocvar)) and checkfreespace(25) = 0 then
			strcmdline = "cmd /c """ & baclocvar & """"
			if debug = 1 then screenout "  (" & strcmdline & ")"
			temp = wshshell.Run(strcmdline, 1, true)
		elseif checkfreespace(25) = 1 then
			text = "  There is not enough free space on the boot drive to install Backup Accelerator!"
			screenout text
			genevent "W", "4", text
			baclogvar = "Not Enough Disk Space"
		else
			text = "  The script could not locate the Backup Accelerator install script!"
			screenout text
			screenout "  (" & baclocvar & ")"
			genevent "W", "4", text
			baclogvar = "No Install File"
		end if
	end if

	if err.number <> 0 then logerror "End of tools_backupexec Function", err.number : err.clear
	tools_backupexec = 0
End Function



REM #################################################################################################
REM ###                                     Other tools stuff                                     ###
REM #################################################################################################
Function tools_other()
	dim text
	on error resume next

	REM ### Check for new switch and set some services to manual start ###
	if argument("/new") <> 0 then
		screenout "Switch to disable monitoring services on New builds detected."
		wshshell.regwrite "HKLM\system\currentcontrolset\services\Sentry Alert Sender (SASS)\start", "3", "REG_DWORD"
		logregistryentry "Sentry Service to manual start", "Changed", "HKLM\system\currentcontrolset\services\Sentry Alert Sender (SASS)\start", "3"
		if err.number <> 0 then err.clear
	end if


	if err.number <> 0 then logerror "End of tools_other Function", err.number : err.clear
	tools_other = 0
End Function



REM #################################################################################################
REM ###                                        WWW Services                                       ###
REM #################################################################################################
Function services_www()
	dim temp, strcmdline, text
	on error resume next

	REM #### Set optimization to Network Application for given services ######
	if wwwvar = "IPAK" then
		if (Wshfile.FileExists(wwwlocvar & "\wwwsetup.vbs"))  then
			wwwlogvar = "Executed"
			screenout "Executing the WWW IPAK script..."
			strcmdline = "cmd /c """ & wwwlocvar & "\wwwsetup " & scriptconswivar & """"
			if debug = 1 then screenout "  (" & strcmdline & ")"
			temp = wshshell.Run(strcmdline, 1, true)
			if err.number <> 0 then err.clear
		else 
			text = "The script could not locate the WWW IPAK install script!"
			screenout text
			screenout "  (" & wwwlocvar & "\wwwsetup.vbs)"
			genevent "W", "4", text
		end if
	else
		wwwlogvar = "Not enabled"
		screenout "WWW IPAK not enabled."
	end if

	if err.number <> 0 then logerror "End of services_www Function", err.number : err.clear
	services_www = 0
End Function




REM #################################################################################################
REM ###                                         Other                                           ###
REM #################################################################################################
Function completion_other()
	dim  text, wshinifile, rkey
	on error resume next

	REM ###### register IPAK event log DLL ######
	screenout "Registering IPAK Event log DLL..."
	genevent "0", "0", "dll"

	REM ###### Create last ran registry entries ######
	enddate=date
	endtime=time
	if fixvar = "off" or fixvar = "switch" then 
		screenout "Removing Last Ran registry identifiers for the IPAK script..."
		if (Wshfile.fileexists(scriptinilocvar & "\DeleteRegKeysW2K.ini")) then 
			Set wshinifile = wshfile.OpenTextFile(scriptinilocvar & "\DeleteRegKeysW2K.ini", 1)
			Do While wshinifile.AtEndOfStream <> true
				rkey = wshiniFile.ReadLine
				wshshell.regdelete rkey
				if err.number <> 0 then err.clear
			loop
			wshinifile.Close
		else
			screenout ""
			text = "The script was unable to find the DeleteRegKeysW2K.ini file!"
			screenout text
			screenout "Make sure that " & scriptinilocvar & " exists and contains the necessary INI file."
			genevent "E", "3", text
			completion_other = 1
			exit function
		end if
		if err.number <> 0 then err.clear
	else
		screenout "Creating Last Ran registry identifiers..."
		wshshell.regwrite "HKLM\software\microsoft\windows nt\currentversion\LastUpdateScript", enddate & " " & endtime, "REG_SZ"
		wshshell.regwrite "HKLM\software\microsoft\windows nt\currentversion\IpakVersion", scriptipakvar , "REG_SZ"
		wshshell.regwrite "HKLM\software\microsoft\windows nt\currentversion\LastUpdateScriptName", scriptnamevar & " - Version " & scriptversionvar, "REG_SZ"
		wshshell.regwrite "HKLM\software\microsoft\windows nt\currentversion\ipak\ipaknt\Version", scriptipakvar , "REG_SZ"
		wshshell.regwrite "HKLM\software\microsoft\windows nt\currentversion\ipak\ipaknt\Scriptinfo", scriptnamevar & " - Version " & scriptversionvar, "REG_SZ"
		wshshell.regwrite "HKLM\software\microsoft\windows nt\currentversion\ipak\ipaknt\installedfrom", scriptpathlocvar, "REG_SZ"
		wshshell.regwrite "HKLM\software\microsoft\windows nt\currentversion\ipak\ipaknt\installedon", enddate & " " & endtime, "REG_SZ"
		wshshell.regwrite "HKLM\software\microsoft\windows nt\currentversion\ipak\ipaknt\installedby", userdomain & "\" & username, "REG_SZ"
		if scriptnetworkvar = "CORPORATE" then
			wshshell.regwrite "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SNMP\Parameters\RFC1156Agent\sysObjectID", "1.3.6.1.4.1.311.24.1", "REG_SZ"
		elseif scriptnetworkvar = "INTERNET" or scriptnetworkvar = "EXTRANET" then
			wshshell.regwrite "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SNMP\Parameters\RFC1156Agent\sysObjectID", "1.3.6.1.4.1.311.24.2", "REG_SZ"
		end if
		if err.number <> 0 then logerror "Creating Last Ran Registry entries", err.number : err.clear
	end if

	if err.number <> 0 then logerror "End of completion_other Function", err.number : err.clear
	completion_other = 0
End Function




REM #################################################################################################
REM ###                                         Logging                                           ###
REM #################################################################################################
Function completion_locallogging()
	dim  wshscriptlogfile, a, text
	on error resume next

	REM ### create logs directory and remove existing logs ###
	if not (Wshfile.folderexists(scriptlogvar)) then Wshfile.createFolder(scriptlogvar)
	if (Wshfile.fileexists(scriptlogvar & "\" & scriptnamevar & ".log")) then wshfile.deletefile scriptlogvar & "\" & scriptnamevar & ".log", TRUE
	if (Wshfile.fileexists(scriptlogvar & "\symbols.log")) then wshfile.deletefile scriptlogvar & "\symbols.log", TRUE
	if (Wshfile.fileexists(tempdir & "\" & computername & ".log")) then wshfile.deletefile tempdir & "\" & computername & ".log", TRUE
	if (Wshfile.fileexists("d:\exchsrvr" & scriptnamevar & ".log")) then wshfile.deletefile "d:\exchsrvr" & scriptnamevar & ".log", TRUE


	REM ###### Create server log ######
	screenout "Creating server log file on local machine..."
	set wshscriptlogfile = wshfile.createtextfile(scriptlogvar & "\" & scriptnamevar & ".log",1)
 	wshscriptlogfile.writeline("")
	wshscriptlogfile.writeline("Script Name: " & scriptnamevar)
	wshscriptlogfile.writeline("Script Version: " & scriptversionvar)
	wshscriptlogfile.writeline("IPAK Version: " & scriptipakvar)
 	wshscriptlogfile.writeline("Date and Time (start): " & begdate & " " & begtime)
 	wshscriptlogfile.writeline("Date and Time (end): " & enddate & " " & endtime)
	wshscriptlogfile.writeline("User Name: " & username)
	wshscriptlogfile.writeline("Arguments: " & argtext)
	wshscriptlogfile.writeline("Configuration Switch: " & scriptconswivar)
	wshscriptlogfile.writeline("Site Location: " & scriptsitevar)
	wshscriptlogfile.writeline("Network Type: " & scriptnetworkvar)
	wshscriptlogfile.writeline("Source Location path: " & scriptpathlocvar)
	wshscriptlogfile.writeline("################ Server Information ####################")
	wshscriptlogfile.writeline("Server Name: " & computername)
	wshscriptlogfile.writeline("Windows Version: " & srvvervar)
	wshscriptlogfile.writeline("Windows Build: " & srvbuildvar)
	wshscriptlogfile.writeline("Product Suite: " & srvsuitevar)
	wshscriptlogfile.writeline("Windows Architecture: " & srvarcvar)
	wshscriptlogfile.writeline("Computer Role: " & srvrolevar)
	wshscriptlogfile.writeline("Encryption Bits: " & srvencvar)
	wshscriptlogfile.writeline("Hardware Platform: " & srvhardwarevar)
	wshscriptlogfile.writeline("Boot Drive Format: " & srvbootvar)
	wshscriptlogfile.writeline("Physical Memory: " & srvmemvar)
	wshscriptlogfile.writeline("Logical Drives: " & harddrives)
	wshscriptlogfile.writeline("CD-ROM Drives: " & cddrives)
	wshscriptlogfile.writeline("################# Hardware Software ####################")
	wshscriptlogfile.writeline("Compaq SSD  " & cpqssdvar & ": " & cpqssdlogvar)
	wshscriptlogfile.writeline("Compaq CIM  " & cpqcimvar & ": " & cpqcimlogvar)
	wshscriptlogfile.writeline("Compaq Storage Works Driver  " & cpqstrdrvvar & ": " & cpqstrdrvlogvar)
	wshscriptlogfile.writeline("Dell Managed Node " & delmannvar & ": " & delmannlogvar)
	wshscriptlogfile.writeline("Dell FAST Utility " & delfastvar & ": " & delfastlogvar)
	wshscriptlogfile.writeline("Dell Perc2 Driver " & deldrvvar & ": " & deldrvlogvar)
	wshscriptlogfile.writeline("################# Update Software ######################")
	wshscriptlogfile.writeline("Recovery Console: " & recconslogvar)
	wshscriptlogfile.writeline("Service Pack: " & splogvar)
	wshscriptlogfile.writeline("Symbols: " & symlogvar)
	wshscriptlogfile.writeline("Hotfixes: " & fixlogvar)
	wshscriptlogfile.writeline("128 Bit Encryption: " & enclogvar)
	wshscriptlogfile.writeline("####################### Tools ##########################")
	wshscriptlogfile.writeline("OpAssist: " & opalogvar)
	wshscriptlogfile.writeline("Sentry: " & senlogvar)
	wshscriptlogfile.writeline("NetIQ: " & niqlogvar)
	wshscriptlogfile.writeline("Inoculan: " & inoclogvar)
	wshscriptlogfile.writeline("Object Inactivity Checker: " & oiclogvar)
	wshscriptlogfile.writeline("Backup Accelerator: " & baclogvar)
	wshscriptlogfile.writeline("################## Windows Services ####################")
	wshscriptlogfile.writeline("TS Changes: " & termvar)
	wshscriptlogfile.writeline("################## Special Services ####################")
	wshscriptlogfile.writeline("WWW Changes: " & wwwvar)
	wshscriptlogfile.writeline("SQL Changes: " & sqlvar)
	wshscriptlogfile.writeline("Exchange Changes: " & exchangevar)
	wshscriptlogfile.writeline("SAP Changes: " & sapvar)
	wshscriptlogfile.writeline("WWW IPAK: " & wwwlogvar)
	wshscriptlogfile.writeline("################### Extra Services #####################")
	wshscriptlogfile.writeline("Installed extra services:")
	wshscriptlogfile.writeline(extraservices)
	wshscriptlogfile.writeline("################## Registry Values #####################")
	for a = 1 to regarrayloc - 1 step 1
		wshscriptlogfile.writeline(regarray(a,1) & " - " & regarray(a,2))
		wshscriptlogfile.writeline("  " & regarray(a,3) & " - " & regarray(a,4))
	next
	wshscriptlogfile.close
	wscript.DisconnectObject wshscriptlogfile
	set wshscriptlogfile=nothing


	REM ###### Create exchange log ######
	if not exchangevar = "" then 
		screenout "Creating Exchange server log file on local machine..."
		set wshscriptlogfile = wshfile.createtextfile("d:\exchsrvr\" & scriptnamevar & ".log",1)
 		wshscriptlogfile.writeline("")
		wshscriptlogfile.writeline("Script Name: " & scriptnamevar)
		wshscriptlogfile.writeline("Script Version: " & scriptversionvar)
 		wshscriptlogfile.writeline("Date and Time (start): " & begdate & " " & begtime)
 		wshscriptlogfile.writeline("Date and Time (end): " & enddate & " " & endtime)
		wshscriptlogfile.writeline("User Name: " & username)
		wshscriptlogfile.writeline("Configuraiton Switch: " & scriptconswivar)
		wshscriptlogfile.writeline("Site Location: " & scriptsitevar)
		wshscriptlogfile.writeline("Network Type: " & scriptnetworkvar)
		wshscriptlogfile.writeline("Source Location path: " & scriptpathlocvar)
		wshscriptlogfile.writeline("################ Server Information ####################")
		wshscriptlogfile.writeline("Server Name: " & computername)
		wshscriptlogfile.writeline("Windows Version: " & srvvervar)
		wshscriptlogfile.writeline("Windows Architecture: " & srvarcvar)
		wshscriptlogfile.writeline("Windows Build: " & srvbuildvar)
		wshscriptlogfile.writeline("Computer Role: " & srvrolevar)
		wshscriptlogfile.writeline("Product Suite: " & srvsuitevar)
		wshscriptlogfile.writeline("Encryption Bits: " & srvencvar)
		wshscriptlogfile.writeline("Hardware Platform: " & srvhardwarevar)
		wshscriptlogfile.writeline("Boot Drive Format: " & srvbootvar)
		wshscriptlogfile.writeline("Physical Memory: " & srvmemvar)
		wshscriptlogfile.writeline("Logical Drives: " & harddrives)
		wshscriptlogfile.writeline("CD-ROM Drives: " & cddrives)
		wshscriptlogfile.writeline("################## Special Services ####################")
		wshscriptlogfile.writeline("Exchange Changes: " & exchangevar)
		wshscriptlogfile.close
		wscript.DisconnectObject wshscriptlogfile
		set wshscriptlogfile=nothing
	end if

	if err.number <> 0 then logerror "End of completion_locallogging Function", err.number : err.clear
	completion_locallogging = 0
End Function




REM #################################################################################################
REM ###                                  Destination Logging                                      ###
REM #################################################################################################
Function completion_destlogging()
	dim  wshscriptlogfile, text, checkaccess
	on error resume next

	REM ##### Exception out test servers for logging ######
	if Instr(1, computername, "mustangs", 1) <> 0 then
		screenout "Destination logs not getting updated as this machine is a test machine."
		completion_destlogging = 0
		exit function
	elseif not (Wshfile.folderexists(scriptloglocvar)) then
		screenout "Logging destination directory cannot be found. Logs will be only be available on the server."
		completion_destlogging = 0
		exit function
	else
		set wshscriptlogfile = wshfile.createtextfile(scriptloglocvar & "\Access.txt")	
		if err.number <> 0 then checkaccess = 1 : err.clear
		wshscriptlogfile.close
		wscript.DisconnectObject wshscriptlogfile
		set wshscriptlogfile=nothing
		if (Wshfile.fileexists(scriptloglocvar & "\access.txt")) then wshfile.deletefile scriptloglocvar & "\access.txt", TRUE
		if checkaccess = 1 then
			screenout "Logging destination directory access problems. Logs will be only be available on the server."
			completion_destlogging = 0
			exit function
		else
			screenout "Manipulating destination logging server logs..."
			REM ###### Create directories if they do not exist ######
			if not (Wshfile.folderexists(scriptloglocvar & "\servers")) then wshfile.createfolder(scriptloglocvar & "\servers")
			if not (Wshfile.folderexists(scriptloglocvar & "\scripts")) then wshfile.createfolder(scriptloglocvar & "\scripts")

			REM ###### Copying server log file to logging destination ######
			screenout "  Copying server log file to destination logging server..."
			if (Wshfile.fileexists(scriptloglocvar & "\servers\" & computername & ".bak.log")) then wshfile.deletefile scriptloglocvar & "\servers\" & computername & ".bak.log", TRUE
			if (Wshfile.fileexists(scriptloglocvar & "\servers\" & computername & "-3.log")) then wshfile.deletefile scriptloglocvar & "\servers\" & computername & "-3.log", TRUE
			if (Wshfile.fileexists(scriptloglocvar & "\servers\" & computername & "-2.log")) then wshfile.copyfile scriptloglocvar & "\servers\" & computername & "-2.log", scriptloglocvar & "\servers\" & computername & "-3.log"
			if (Wshfile.fileexists(scriptloglocvar & "\servers\" & computername & "-1.log")) then wshfile.copyfile scriptloglocvar & "\servers\" & computername & "-1.log", scriptloglocvar & "\servers\" & computername & "-2.log"
			if (Wshfile.fileexists(scriptloglocvar & "\servers\" & computername & ".log")) then wshfile.copyfile scriptloglocvar & "\servers\" & computername & ".log", scriptloglocvar & "\servers\" & computername & "-1.log"
			if (Wshfile.fileexists(scriptlogvar & "\" & scriptnamevar & ".log")) then wshfile.copyfile scriptlogvar & "\" & scriptnamevar & ".log", scriptloglocvar & "\servers\" & computername & ".log"


			REM ###### Append to Script log on logging destination ######
			screenout "  Appending information to script log on destination logging server..."
			if (Wshfile.fileexists(scriptloglocvar & "\scripts\_" & scriptnamevar & scriptversionvar & ".log")) then 
				set wshscriptlogfile = wshfile.opentextfile(scriptloglocvar & "\scripts\_" & scriptnamevar & scriptversionvar & ".log",8)
			else
				set wshscriptlogfile = wshfile.createtextfile(scriptloglocvar & "\scripts\_" & scriptnamevar & scriptversionvar & ".log",1)
			end if
			wshscriptlogfile.writeline computername& " - " & begdate & " " & begtime   & " - " & enddate & " " & endtime  & " - " & srvbuildvar & " - " & scriptipakvar & " - " & username
			wshscriptlogfile.close
			wscript.DisconnectObject wshscriptlogfile
			set wshscriptlogfile=nothing
		end if
	end if

	if err.number <> 0 then logerror "End of completion_destlogging Function", err.number : err.clear
	completion_destlogging = 0
End Function




REM #################################################################################################
REM ###                                         Reboot                                            ###
REM #################################################################################################
Function completion_reboot()
	dim  temp, strcmdline, text, reboot
	on error resume next

	REM #### Delete temporary directory ######
	if argument("config") <> 0 or argument("setup") <> 0 or argument("bug") <> 0 then
	else
		wshfile.deletefolder scripttempvar, TRUE
		if err.number <> 0 then err.clear
	end if

	genevent "S", "2", scriptnamevar & " for IPAK " & scriptipakvar & " Completed Successfully."
	if scriptrebootvar  = "reboot" then
		screenout "The server is now being rebooted by " & scriptnamevar & "..."
		genevent "I", "5", "Server was rebooted by " & scriptnamevar & "."
		strCmdLine = "cmd /c """& scriptfileslocvar & "\reboot /L /R /T:10"""
		temp = wshshell.Run(strcmdline, 0, true)
	elseif scriptrebootvar = "ask" then
		screenout "The server should now be rebooted."
		reboot = msgbox("Do you wish to reboot the server now?", 20, scriptnamevar & " - Reboot Server?")
		if reboot = 6 then
			screenout "The server is now being rebooted by " & scriptnamevar & "..."
			genevent "I", "5", "Server was rebooted by " & scriptnamevar & "."
			strCmdLine = "cmd /c """& scriptfileslocvar & "\reboot /L /R /T:5"""
			temp = wshshell.Run(strcmdline, 0, true)
		else
			text = "The server must be rebooted for changes to take effect!"
			screenout text
			genevent "W", "4", text
		end if	 
	else
		text = "The server must be rebooted for changes to take effect!"
		screenout text
		genevent "W", "4", text
	end if

	if err.number <> 0 then logerror "End of completion_reboot Function", err.number : err.clear
	completion_reboot = 0		
End Function






REM #################################################################################################
REM ###                                                                                           ###
REM ###                                   Global Functions                                        ###
REM ###                                                                                           ###
REM #################################################################################################
REM #################################################################################################
REM ###                                       Screen Out                                          ###
REM #################################################################################################
Function screenout(text)
	dim wsherrorlogfile
	on error resume next

	wscript.echo text
	if (Wshfile.fileexists(systemdrive & "\" & scriptnamevar & "-run.log")) then 
		set wsherrorlogfile = wshfile.openTextfile(systemdrive & "\" & scriptnamevar & "-run.log",8)
 		wsherrorlogfile.writeline(text)
		wsherrorlogfile.close
		wscript.DisconnectObject Wsherrorlogfile
		set Wsherrorlogfile=nothing
		if err.number <> 0 then err.clear
	else
		set wsherrorlogfile = wshfile.createtextfile(systemdrive & "\" & scriptnamevar & "-run.log",1)
 		wsherrorlogfile.writeline(text)
		wsherrorlogfile.close
		wscript.DisconnectObject Wsherrorlogfile
		set Wsherrorlogfile=nothing
		if err.number <> 0 then err.clear
	end if

End Function




REM #################################################################################################
REM ###                                   Registry writes                                         ###
REM #################################################################################################
Function logregistryentry(text, status, rkey, rvalue)
	dim wshbootdrive, freespace
	on error resume next

		regarray(regarrayloc,1) = text
		regarray(regarrayloc,2) = status
		regarray(regarrayloc,3) = rkey
		regarray(regarrayloc,4) = rvalue
		regarrayloc = regarrayloc + 1

End Function




REM #################################################################################################
REM ###                                Argument Function                                          ###
REM #################################################################################################
Function argument(sttext)
	dim a
	on error resume next

	for a = 0 to wscript.arguments.count - 1
		if wscript.arguments(a) = sttext then argument = a + 1
	next

End Function



REM #################################################################################################
REM ###                                NextArgument Function                                      ###
REM #################################################################################################
Function nextargument(location)
	dim sttext
	on error resume next

	if wscript.arguments.count - 1 < location - 1 then
		sttext = ""
	else
		sttext = wscript.arguments(location)
	end if
	nextargument = sttext

End Function



REM #################################################################################################
REM ###                                GetArgument Function                                       ###
REM #################################################################################################
Function getargument(location)
	dim sttext
	on error resume next

	if wscript.arguments.count - 1 < location - 1 then
		sttext = ""
	else
		sttext = wscript.arguments(location - 1)
	end if
	getargument = sttext

End Function



REM #################################################################################################
REM ###                                InArgument Function                                          ###
REM #################################################################################################
Function inargument(sttext)
	dim a
	on error resume next

	for a = 0 to wscript.arguments.count - 1
		if instr(1, wscript.arguments(a), sttext, 1) <> 0 then inargument = a + 1
	next

End Function



REM #################################################################################################
REM ###                                    Check Freespace                                        ###
REM #################################################################################################
Function checkfreespace(size)
	dim wshbootdrive, freespace
	on error resume next

	Set wshbootdrive = wshfile.GetDrive(systemdrive)
	freespace = int(formatnumber(wshbootdrive.freespace/1048576,0))
	Wscript.DisconnectObject Wshbootdrive
	if freespace < size then
		checkfreespace = 1
	else
		checkfreespace = 0
	end if
	Set Wshbootdrive=nothing

End Function




REM #################################################################################################
REM ###                             Wait until text is found or not found                         ###
REM #################################################################################################
Function waituntil(there, notthere)
	dim alltext, checkpoint, strcmdline, temp, wshtempfile
	on error resume next

	REM ###### Loop until first arg is found or second arg is not found ######
	checkpoint = 0
	Do While checkpoint = 0
		strCmdLine = "cmd /c """& scriptfileslocvar & "\tlist >" & scripttempvar & "\tlisttemp.txt"""
		temp = wshshell.Run(strcmdline, 0, true)
		if err.number <> 0 then err.clear
		Set wshtempfile = wshfile.OpenTextFile(scripttempvar & "\tlisttemp.txt", 1)
		alltext = wshtempFile.Readall
		wshtempfile.Close
		wscript.DisconnectObject wshtempfile
		Set wshtempfile=nothing
		rem screenout "First Arg - " & there & " - " & instr(1, alltext, there, 1)
		rem screenout "Second Arg - " & notthere & " - " & instr(1, alltext, notthere, 1)
		if not there = "" and not instr(1, alltext, there, 1) = 0 then
			waituntil = 0
			checkpoint = 1
			wscript.sleep 5000 * netfactor
		end if
		if not notthere = "" and instr(1, alltext, notthere, 1) = 0 then
			waituntil = 1
			checkpoint = 1
		end if
	Loop

	if err.number <> 0 then logerror "End of WaitUntil Function", err.number : err.clear
end function




REM #################################################################################################
REM ###                                   Manipulate a window                                     ###
REM #################################################################################################
Function winmanipulate(check, popup, key)
	dim strcmdline, temp, wshtempfile, alltext
	on error resume next

	REM ###### Check for open window and manipulate that window ######
	strCmdLine = "cmd /c """& scriptfileslocvar & "\tlist >" & scripttempvar & "\tlisttemp.txt"""
	temp = wshshell.Run(strcmdline, 0, true)
	if err.number <> 0 then err.clear
	Set wshtempfile = wshfile.OpenTextFile(scripttempvar & "\tlisttemp.txt", 1)
	alltext = wshtempFile.Readall
	wshtempfile.Close
	wscript.DisconnectObject wshtempfile
	Set wshtempfile=nothing
	if check = "" or not instr(1, alltext, check, 1) = 0 then
		rem screenout popup
		rem screenout key
		wshshell.appactivate popup
		wscript.sleep 2000 * netfactor
		wshshell.sendkeys key
		winmanipulate = 0
	else
		winmanipulate = 1
	end if

	if err.number <> 0 then logerror "End of WinManipulate Function", err.number : err.clear
end function




REM #################################################################################################
REM ###                                       Error logging                                       ###
REM #################################################################################################
Function logerror(location, error)
	on error resume next
	screenout "******************************************************"
	screenout "******** Description: Script Error"
	screenout "******** Script Location: " & location
	screenout "******** Error Code: " & error
	screenout "******** User Action: Check the IPAK " & scriptipakvar & " TSG on Http://gnsweb/ipak"
	screenout "********              If the TSG does not contain any information, then fill out the"
	screenout "********              escalation template on Http://gnsweb/ipak and submit."
	screenout "******************************************************"
	genevent "E", "4", "Error with internal scripting component - (Description: " & location & "Error: " & error & ")"
	logerror = 0
End Function




REM #################################################################################################
REM ###                                   Generate Eventlog Entry                                 ###
REM #################################################################################################
Function genevent(severity, eventid, description)
	dim strcmdline, temp
	on error resume next

	if severity = eventid and description = "dll" then 
		strCmdLine = "cmd /c """& scriptfileslocvar & "\ipakevnt"""""
		temp = wshshell.Run(strcmdline, 0, true)
	else
		strCmdLine = "cmd /c """& scriptfileslocvar & "\ipakevnt -s " & severity & " -c " & eventid & " -r ""IPAKNT"" -e 200" & eventid & " """ & description & """"""
		rem if debug = 1 then screenout strcmdline
		temp = wshshell.Run(strcmdline, 0, true)
		if severity = "E" and eventid = 3 then temp = msgbox(description, 0, scriptnamevar & " - ERROR!")

	end if

	if err.number <> 0 then logerror "End of GenEvent Function", err.number : err.clear
	genevent = 0
End Function




REM #################################################################################################
REM ###                                        Data Compare                                       ###
REM #################################################################################################
Function datecomp(date1, date2)
	dim daydiff
	on error resume next

		if isdate(date1) and isdate(date2) then
			daydiff = datediff("d", date1, date2)
		else
			daydiff = -1
		end if
		if daydiff >= 0 then
			datecomp = True
		else
			datecomp = false
		end if

	if err.number <> 0 then logerror "End of Datecomp Function", err.number : err.clear
End Function





REM #################################################################################################
REM ###                                     Get Build CD                                          ###
REM #################################################################################################
Function getbuildcd()
	dim description, temp
	on error resume next

	if recconsvar = "off" or not srvbootvar = "NTFS" or recconsvar = "switch" then
	elseif cdrunvar = "on" or argument("forcecd") <> 0 then
		do while (Wshfile.folderexists(bldlocvar)) = false
			description = "Please insert the 'ITG Build CD (SP1 Series)', Version 7.40 or newer into the CD-ROM!"
			temp = msgbox(description, 0, scriptnamevar & " - Need Build CD!")
			if debug = 1 then screenout "  " & bldlocvar
		loop
		screenout "Found Build CD OK."
	end if

End Function





REM #################################################################################################
REM ###                                     Get Tools CD                                          ###
REM #################################################################################################
Function gettoolscd()
	dim description, temp
	on error resume next

	if argument("/notools") <> 0 then
	elseif cdrunvar = "on" or argument("forcecd") <> 0 then
		do while (Wshfile.fileexists(opalocvar)) = false
			description = "Please insert the 'ITG Tools CD', Version 1.00 or newer into the CD-ROM!"
			temp = msgbox(description, 0, scriptnamevar & " - Need Tools CD!")
			if debug = 1 then screenout "  " & opalocvar
		loop
		screenout "Found Tools CD OK."
	end if

End Function





REM #################################################################################################
REM ###                                    Get Update CD                                          ###
REM #################################################################################################
Function getupdatecd()
	dim description, temp
	on error resume next

	if cdrunvar = "on" or argument("forcecd") <> 0 then
		do while (Wshfile.fileexists(scriptpathlocvar & "\" & scriptnamevar & ".vbs")) = false
			description = "Please insert the 'ITG Update CD' for IPAK NT5.02 into the CD-ROM!"
			temp = msgbox(description, 0, scriptnamevar & " - Need Update CD!")
			if debug = 1 then screenout "  " & scriptpathlocvar & "\" & scriptnamevar & ".vbs"
		loop
		screenout "Found Update CD OK."
	end if

End Function





REM #################################################################################################
REM ###                                           Syntax                                          ###
REM #################################################################################################
Function syntax()
	on error resume next

	screenout ""
	screenout ""
	screenout "Name: " & scriptnamevar
	screenout "Usage: " & scriptnamevar & " [Configuration Switch] [Other Switches]"
	screenout "Description: " & scriptnamevar & " is used to update/config software on production W2K servers at Microsoft."
	screenout "Switches:"
	screenout "    Configuration Switch Syntax (One Required):"
	screenout "      /'location'-'network'"
	screenout "        'location' description:"
	screenout "           b11 - Building 11 configuration"
	screenout "           cp -  Canyon Park Data Center configuration"
	screenout "           tuk - Tukwila Data Center configuration"
	screenout "           sat - Saturn Lab configuration"
	screenout "           jup - Jupiter Lab configuration"
	screenout "           soc - MSN/SOC configuration"
	screenout "           dsk - Desk Top Machine configuration"
	screenout "           noam - North America configuration"
	screenout "           soam - South America configuration"
	screenout "           euro - Europe configuration"
	screenout "           sopa - South Pacific configuration"
	screenout "           faea - Far East configuration"
	screenout "           miea - Middle East configuration"
	screenout "           afca - Africa configuration"
	screenout "        'network' description:"
	screenout "           corp - Server on the Corporate network"
	screenout "           int - Server on the Internet network"
	screenout "           pri - Server on a Private network"
	screenout "           ext - Server on the Extranet network"
	screenout "    Examples:"
	screenout "      " & scriptnamevar & " /b11-corp"
	screenout "      " & scriptnamevar & " /noam-corp"
	screenout "      " & scriptnamevar & " /euro-corp"
	screenout "    Other Switches (optional):"
	screenout "        /com      - Forces the script to set hardware platform to Compaq."
	screenout "        /del      - Forces the script to set hardware platform to Dell."
	screenout "        /oth      - Forces the script to set hardware platform to other."
	screenout "                      No Compaq or Dell Components."
	screenout "        /nocim    - Forces the script to NOT install CIM."
	screenout "        /nostrwrk - Forces the script to NOT make any changes for Storage Works."
	screenout "        /allfixes - Enables install of ALL additional Hotfixes."
	screenout "        /fullsym  - Forces the script to copy files for the Full Symbol set."
	screenout "        /clrsym   - Forces the script to clear existing symbols and not copy in new ones."
	screenout "        /noupd    - Forces the script to NOT update the Windows components."
	screenout "                      No Service Pack, Hotfixes, or Symbols."
	screenout "        /reb      - Forces the script to automatically reboot when completed."
	screenout "        /noreb    - Forces the script to NOT reboot and end when completed."
	screenout "        /debug    - Forces the script to set full debugger settings."
	screenout "        /forceup  - Enables the script to update ALL up-to-date components."
	screenout "                      Except: Dell Management Software - Software will hang."
	screenout "        /slownet '#' - Gives the script a multipler to slow down the screen manipulations"
	screenout "                        for slow network links. A 2 causes the script to wait twice as"
	screenout "                        long before manipulating the screens."
	screenout "        /inocon   - Enables the Inoculan install on File Servers."
	screenout "        /buacon   - Enables the Backup Accelerator install."
	screenout "        /noopa    - Forces the script to NOT install OpAssist."
	screenout "        /nosen    - Forces the script to NOT install Sentry."
	screenout "        /noniq    - Forces the script to NOT install NetIQ."
	screenout "        /noinoc   - Forces the script to NOT update or install Inoculan."
	screenout "        /nooic    - Forces the script to NOT install Object Inactivity Checker. (DC's ONLY!)"
	screenout "        /nobac    - Forces the script to NOT install Backup Accelerator."
	screenout "        /notools  - Forces the script to NOT install any of the Tools."
	screenout "                      No Opassist, Sentry, NetIQ, Inoculan, OIC, or Backup Accelerator."
	screenout "        /nobitmap - Forces the script to NOT change the background bitmap."
	screenout "        /new      - Forces the script to set Sentry services to Manual start for new builds."
	screenout "        /wwwreg   - Forces the script to make NT registry changes for WWW services."
	screenout "        /sqlreg   - Forces the script to make NT registry changes for SQL services."
	screenout "        /excreg   - Forces the script to make NT registry changes for Exchange services."
	screenout "        /sapreg   - Forces the script to make NT registry changes for SAP services."
	screenout "        /wwwipak  - Enables execution of the WWW IPAK script."

	syntax=1
End Function