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
100
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
|
On Error Resume Next
' Constants for FileSystemObject
Const FOR_READING = 1
Const FOR_WRITING = 2
Const FOR_APPENDING = 8
' Paths to input and output files. Input file must be a comma-delimited text
' file on same machine where script is to be run with name of accessible
' machine and other settings on each line.
strFileInput = "c:\scripts\clients.csv"
strFileOutput = "c:\scripts\newclients.csv"
' Counters for final tally
intAdd = 0
intUpdate = 0
intRemove = 0
intError = 0
Set objFSO = CreateObject("Scripting.FileSystemObject")
strInput = GetInput(strFileInput)
' Get computer info by breaking input stream into array at line breaks.
arrClients = Split(strInput, VbCrLf)
' Check to see if the output file exists. If so, open it for appending.
' If not, create it and open it for writing.
If objFSO.FileExists(strFileOutput) Then
Set objOutputFile = objFSO.OpenTextFile(strFileOutput, FOR_APPENDING)
Else
Set objOutputFile = objFSO.CreateTextFile(strFileOutput)
End If
If Err <> 0 Then
Wscript.Echo "Unable to open " & strFileOutput & " for output."
WScript.Quit
End If
' Write header for file.
objOutputFile.WriteLine "Date: " & Now & VbCrLf & "Adding updating or " & _
"removing " & (UBound(arrClients) + 1) & " new client computers." & _
VbCrLf & VbCrLf & String(120, "-") & VbCrLf
For Each strClient In arrClients
' Get settings by breaking each computer info array at commas.
strComputer = ""
arrParams = Split(strClient, ",")
strComputer = arrParams(0)
WScript.Echo VbCrLf & "Host: " & strComputer & VbCrLf
' Ping remote computer. If no response, display error message and end script.
blnPingSuccess = PingClient(strComputer)
If blnPingSuccess = True Then
' Connect to the WMI service.
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
If Err = 0 Then
Err.Clear
strAddRemove = arrParams(1)
strIpAlloc = arrParams(2)
arrIPAddresses = Split(arrParams(3))
arrSubnetMasks = Split(arrParams(4))
arrDefaultGateways = Split(arrParams(5))
arrGatewayCostMetrics = Split(arrParams(6))
blnDNSChanges = arrParams(7)
arrDNSServerSearchOrder = Split(arrParams(8))
strDNSHostName = arrParams(9)
strDNSDomain = arrParams(10)
arrDNSDomainSuffixSearchOrder = Split(arrParams(11))
blnFullDNSRegistrationEnabled = arrParams(12)
blnDomainDNSRegistrationEnabled = arrParams(13)
blnWINSChanges = arrParams(14)
intNetbiosTcpip = arrParams(15)
blnDNSEnabledForWINSResolution = arrParams(16)
blnWINSEnableLMHostsLookup = arrParams(17)
strWINSHostLookupFile = arrParams(18)
strWINSScopeID = arrParams(19)
strWINSPrimaryServer = arrParams(20)
strWINSSecondaryServer = arrParams(21)
' Write header for each computer.
objOutputFile.WriteLine "Host: " & strComputer & VbCrLf & VbCrLf & _
",Settings before changes:" & VbCrLf
' Get current settings and write to output file.
GetSettings
objOutputFile.WriteLine VbCrLf & "," & String(60, "-")
If LCase(strAddRemove) = "add" Then
objOutputFile.WriteLine VbCrLf & ",TCP/IP client change mode" & _
VbCrLf & VbCrLf & ",Client to be added to network. " & VbCrLf & _
",Administrator must make corresponding changes on servers."
intAdd = intAdd + 1
ElseIf LCase(strAddRemove) = "remove" Then
objOutputFile.WriteLine VbCrLf & ",TCP/IP client change mode" & _
VbCrLf & VbCrLf & ",Client to be removed from network. " & VbCrLf & _
",Administrator must make corresponding changes on servers."
intRemove = intRemove + 1
RemoveClient
Else
objOutputFile.WriteLine VbCrLf & ",TCP/IP client change mode" & _
VbCrLf & VbCrLf & ",Settings to be updated on existing client. " & _
VbCrLf & ",Administrator may have to make corresponding changes " & _
"on servers."
intUpdate = intUpdate + 1
End If
If LCase(strIpAlloc) = "dhcp" Then
SetDHCP
ElseIf LCase(strIpAlloc) = "staticip" Then
SetStaticIP
Else
objOutputFile.WriteLine VbCrLf & ",IP allocation changes" & VbCrLf & _
VbCrLf & ",No changes made in = IP allocation settings."
End If
If blnDNSChanges Then
SetDNS
Else
objOutputFile.WriteLine VbCrLf & ",DNS changes" & VbCrLf & _
VbCrLf & ",No changes made in DNS settings."
End If
objOutputFile.WriteLine VbCrLf & ",NetBIOS & WINS changes" & VbCrLf
If blnWINSChanges Then
blnNetbiosSet = SetNetbios
If blnNetbiosSet = True Then
Select Case intNetbiosTcpip
Case 0
objOutputFile.WriteLine VbCrLf & ",NetBIOS settings from " _
& "DHCP server used. WINS parameters not set."
Case 1
strOutput = VbCrLf & ",NetBIOS over TCP/IP enabled. " _
& "Setting WINS parameters ..." & VbCrLf
blnWinsSet = SetWins
If blnWinsSet = True Then
strOutput = strOutput & ",WINS enabled and parameters set."
Else
strOutput = strOutput & ",Unable to enable WINS and set " & _
"parameters."
End If
objOutputFile.WriteLine strOutput
Case 2
objOutputFile.WriteLine VbCrLf & ",NetBIOS over TCP/IP " & _
"disabled. WINS parameters not set."
Case Else
objOutputFile.WriteLine VbCrLf & ",Could not determine " & _
"setting for NetBIOS Over TCP/IP. WINS parameters not set."
End Select
Else
objOutputFile.WriteLine ",NetBIOS Over TCP/IP setting does " & _
"not require setting WINS parameters."
End If
Else
objOutputFile.WriteLine ",No changes made in NetBIOS & WINS " & _
"settings."
End If
objOutputFile.WriteLine VbCrLf & "," & String(60, "-") & VbCrLf & _
VbCrLf & ",Settings after changes:" & VbCrLf
GetSettings
objOutputFile.WriteLine VbCrLf & String(120, "-") & VbCrLf
Else
objOutputFile.WriteLine "Host: " & strComputer & VbCrLf _
& VbCrLf & ",Error connecting to WMI service." & VbCrLf & _
",Error Number: " & Err.Number & VbCrLf & _
",Error Source: " & Err.Source & VbCrLf & _
",Error Description: " & Err.Description & VbCrLf & VbCrLf & _
String(120, "-") & VbCrLf
Err.Clear
intError = intError + 1
End If
Else
objOutputFile.WriteLine "Host: " & strComputer & VbCrLf _
& VbCrLf & ",Unable to connect." & VbCrLf & VbCrLf & _
String(120, "-") & VbCrLf
intError = intError + 1
End If
Next
' Write footer for file and close.
objOutputFile.WriteLine "Summary: " & VbCrLf & _
"Added " & intAdd & " new client computers." & VbCrLf & _
"Updated " & intUpdate & " client computers." & VbCrLf & _
"Removed " & intRemove & " client computers." & VbCrLf & _
"Unable to connect to or bind to WMI service on " & intError & _
" client computers." & VbCrLf & VbCrLf & String(64, "=") & VbCrLf
objOutputFile.Close
WScript.Echo VbCrLf & "Data written to " & strFileOutput & "."
'******************************************************************************
Function GetInput(strFileInput)
' Check to see if the input file exists.
' If so, dump contents of input file into a string.
If objFSO.FileExists(strFileInput) Then
Set objInputFile = objFSO.GetFile(strFileInput)
If objInputFile.Size > 0 Then
Set objInputFile = objFSO.OpenTextFile(strFileInput, FOR_READING)
strInputStream = objInputFile.ReadAll
objInputFile.Close
GetInput = strInputStream
Else
Wscript.Echo strFileInput & " is empty."
WScript.Quit
End If
Else
WScript.Echo strFileInput & " does not exist on this computer."
WScript.Quit
End If
End Function
'******************************************************************************
Function PingClient(strComputer)
Set objShell = CreateObject("WScript.Shell")
Set objExec = objShell.Exec("ping -n 2 -w 1000 " & strComputer)
strPingResults = LCase(objExec.StdOut.ReadAll)
If InStr(strPingResults, "reply from") Then
PingClient = True
Else
PingClient = False
End If
End Function
'******************************************************************************
Sub GetSettings
Set colCompSystems = objWMIService.ExecQuery _
("SELECT * FROM Win32_ComputerSystem")
' Write header for each computer.
For Each objCompSystem in colCompSystems
intDomainRole = objCompSystem.DomainRole
Select Case intDomainRole
Case 0 strDomainRole = "Standalone Workstation"
Case 1 strDomainRole = "Member Workstation"
Case 2 strDomainRole = "Standalone Server"
Case 3 strDomainRole = "Member Server"
Case 4 strDomainRole = "Backup Domain Controller"
Case 5 strDomainRole = "Primary Domain Controller"
Case Else strDomainRole = "Unable to determine domain role."
End Select
sngOsVer = GetOsVer
If sngOsVer > 5 Then
If objCompSystem.PartOfDomain Then
strDomain = ",Domain:,," & objCompSystem.Domain
Else
strDomain = ",Workgroup:,," & objCompSystem.Workgroup
End If
Else
strDomain = ",Domain or Workgroup:,," & objCompSystem.Domain
End If
objOutputFile.WriteLine ",Computer Name:,," & LCase(objCompSystem.Name) _
& VbCrLf & strDomain & VbCrLf & ",Domain Role:,," & strDomainRole
Next
Set colNicConfigs = objWMIService.ExecQuery _
("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")
For Each objNicConfig In colNicConfigs
' Output network adapter headings
intIndex = objNicConfig.Index
Set objNic = objWMIService.Get("Win32_NetworkAdapter.DeviceID=" & intIndex)
strAdapterType = objNic.AdapterType
If IsEmpty(strAdapterType) Or IsNull(strAdapterType) Then
strAdapterType = "Network"
End If
If sngOsVer > 5 Then
strNetConn = objNic.NetConnectionID
Else
strNetConn = intIndex
End If
strRow = VbCrLf & "," & strAdapterType & " Adapter " & strNetConn & _
VbCrLf & ",,Index " & intIndex & VbCrLf & _
",," & objNicConfig.Description & VbCrLf
objOutputFile.WriteLine strRow
' Output IP allocation settings
strRow = ",,DHCP Enabled: " & objNicConfig.DHCPEnabled & _
VbCrLf & ",,DHCP Server: " & objNicConfig.DHCPServer & VbCrLf
strIPAddresses = ""
If Not IsNull(objNicConfig.IPAddress) Then
For Each strIPAddress In objNicConfig.IPAddress
strIPAddresses = strIPAddresses & VbCrLf & ",,,," & strIPAddress
Next
End If
strRow = strRow & ",,IP Addresses: " & strIPAddresses & VbCrLf
strIPSubnets = ""
If Not IsNull(objNicConfig.IPSubnet) Then
For Each strIPSubnet In objNicConfig.IPSubnet
strIPSubnets = strIPSubnets & VbCrLf & ",,,," & strIPSubnet
Next
End If
strRow = strRow & ",,Subnet Masks: " & strIPSubnets & VbCrLf
strDefaultIPGateways = ""
If Not IsNull(objNicConfig.DefaultIPGateway) Then
For Each strDefaultIPGateway In objNicConfig.DefaultIPGateway
strDefaultIPGateways = strDefaultIPGateways & VbCrLf & _
",,,," & strDefaultIPGateway
Next
End If
strRow = strRow & ",,Default Gateways: " & strDefaultIPGateways & VbCrLf
strGatewayCostMetrics = ""
If Not IsNull(objNicConfig.GatewayCostMetric) Then
For Each strGatewayCostMetric In objNicConfig.GatewayCostMetric
strGatewayCostMetrics = strGatewayCostMetrics & VbCrLf & _
",,,," & strGatewayCostMetric
Next
End If
strRow = strRow & ",,Gateway Cost Metrics: " & strGatewayCostMetrics
objOutputFile.WriteLine strRow
' Output DNS settings
strDNSServerSO = ""
If Not IsNull(objNicConfig.DNSServerSearchOrder) Then
For Each strDNSServer In objNicConfig.DNSServerSearchOrder
strDNSServerSO = strDNSServerSO & VbCrLf & ",,,," & strDNSServer
Next
End If
strRow = ",,DNS Server Search Order:,," & strDNSServerSO & VbCrLf & _
",,DNS Domain:,," & objNicConfig.DNSDomain & VbCrLf
strDNSDomainSuffixes = ""
If Not IsNull(objNicConfig.DNSDomainSuffixSearchOrder) Then
For Each strDNSDomainSuffix In objNicConfig.DNSDomainSuffixSearchOrder
strDNSDomainSuffixes = strDNSDomainSuffixes & strDNSDomainSuffix & ",,"
Next
End If
strRow = strRow & ",,DNS Domain Suffix Search Order:,," & _
strDNSDomainSuffixes & VbCrLf & ",,Domain DNS Registration Enabled: " & _
objNicConfig.DomainDNSRegistrationEnabled & VbCrLf & _
",,Full DNS Registration Enabled: " & _
objNicConfig.FullDNSRegistrationEnabled
objOutputFile.WriteLine strRow
' Output WINS & NetBIOS settings
intNetBIOS = objNicConfig.TcpipNetbiosOptions
Select Case intNetBIOS
Case 0 strNetBIOS = "Use NetBIOS setting from the DHCP server"
Case 1 strNetBIOS = "Enable NetBIOS over TCP/IP"
Case 2 strNetBIOS = "Disable NetBIOS over TCP/IP"
End Select
strRow = ",,NetBIOS Over TCP/IP: " & strNetBIOS & VbCrLf & _
",,Primary WINS Server: " & objNicConfig.WINSPrimaryServer & VbCrLf & _
",,Secondary WINS Server: " & objNicConfig.WINSSecondaryServer & _
VbCrLf & ",,DNS Enabled For WINS Resolution: " & _
objNicConfig.DNSEnabledForWINSResolution & VbCrLf & _
",,WINS Enable LMHosts Lookup: " & _
objNicConfig.WINSEnableLMHostsLookup & VbCrLf & _
",,WINS Host Lookup File: " & _
objNicConfig.WINSHostLookupFile & VbCrLf & _
",,WINS Scope ID: " & objNicConfig.WINSScopeID
objOutputFile.WriteLine strRow
Next
End Sub
'******************************************************************************
Sub RemoveClient
Set colNicConfigs = objWMIService.ExecQuery _
("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")
objOutputFile.WriteLine VbCrLf & ",Removing client from network ..."
For Each objNicConfig In colNicConfigs
objOutputFile.WriteLine VbCrLf & ",Network Adapter " & objNicConfig.Index & _
VbCrLf & ",," & objNicConfig.Description & VbCrLf
If Not objNicConfig.DHCPEnabled Then
strRow = ",,Attempting to set IP address to 0.0.0.0 ..."
intStaticRet = objNicConfig.EnableStatic("0.0.0.0", "255.255.255.255")
If intStaticRet = 0 Then
strSuccess = ",,,Set static IP address to 0.0.0.0."
Else
strSuccess = ",,,Unable to set static IP address."
End If
objOutputFile.WriteLine strRow & VbCrLf & strSuccess
Else
intReleaseRet = objNicConfig.ReleaseDHCPLease
If intReleaseRet = 0 Then
strSuccess = ",,,DHCP lease successfully released."
intStaticRet = objNicConfig.EnableStatic("0.0.0.0", "255.255.255.255")
If intStaticRet = 0 Then
strSuccess = strSuccess & " Set static IP address to 0.0.0.0."
Else
strSuccess = strSuccess & " Unable to set static IP address."
End If
Else
strSuccess = ",,,Unable to release DHCP lease."
End If
objOutputFile.WriteLine strRow & VbCrLf & strSuccess
End If
Next
End Sub
'******************************************************************************
Sub SetDHCP
Set colNicConfigs = objWMIService.ExecQuery _
("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")
objOutputFile.WriteLine VbCrLf & ",DHCP changes"
For Each objNicConfig In colNicConfigs
objOutputFile.WriteLine VbCrLf & ",Network Adapter " & objNicConfig.Index & _
VbCrLf & ",," & objNicConfig.Description & VbCrLf
If Not objNicConfig.DHCPEnabled Then
strRow = ",,Attempting to enable DHCP ..."
intEnableDHCP = objNicConfig.EnableDHCP
If intEnableDHCP = 0 Then
strSuccess = ",,,DHCP successfully enabled."
Else
strSuccess = ",,,Unable to enable DHCP."
End If
objOutputFile.WriteLine strRow & VbCrLf & strSuccess
Else
objOutputFile.WriteLine strRow & ",,DHCP already enabled"
End If
Next
End Sub
'******************************************************************************
Sub SetStaticIP
Set colNicConfigs = objWMIService.ExecQuery _
("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")
objOutputFile.WriteLine VbCrLf & ",Static IP changes"
For Each objNicConfig In colNicConfigs
objOutputFile.WriteLine VbCrLf & ",Network Adapter " & objNicConfig.Index & _
VbCrLf & ",," & objNicConfig.Description & VbCrLf
If objNicConfig.DHCPEnabled Then
strRow = ",,Attempting to disable DHCP and enable static IP ..." & VbCrLf
Else
strRow = ",,Static IP addressing already enabled. Changing " & _
"static IP settings ..." & VbCrLf
End If
If (Not(IsNull(arrIPAddresses(0)))) And _
(Not(IsEmpty(arrIPAddresses(0)))) And _
(Not(IsNull(arrSubnetMasks(0)))) And _
(Not(IsEmpty(arrSubnetMasks(0)))) Then
intStaticReturn = objNicConfig.EnableStatic(arrIPAddresses, arrSubnetMasks)
If intStaticReturn = 0 Then
strRow = strRow & ",,DHCP disabled - static IP address enabled." & VbCrLf
If (Not(IsNull(arrDefaultGateways(0)))) And _
(Not(IsEmpty(arrDefaultGateways(0)))) And _
(Not(IsNull(arrGatewayCostMetrics(0)))) And _
(Not(IsEmpty(arrGatewayCostMetrics(0)))) Then
Set objNicChanged = objWMIService.Get _
("Win32_NetworkAdapterConfiguration.Index=" & objNicConfig.Index)
intGatewaysReturn = objNicChanged.SetGateways _
(arrDefaultGateways, arrGatewayCostMetrics)
If intGatewaysReturn = 0 Then
strRow = strRow & ",,Assigned new default gateways."
Else
strRow = strRow & ",,Unable to assign default gateways."
End If
Else
strRow = strRow & ",,No new default gateway or cost metric " & _
"listed in input."
End If
Else
strRow = strRow & ",,Unable to enable static IP address."
End If
Else
strRow = strRow & ",,No new static IP address or subnet mask " & _
"listed in input."
End If
objOutputFile.WriteLine strRow
Next
End Sub
'******************************************************************************
Sub SetDNS
Set colNicConfigs = objWMIService.ExecQuery _
("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")
objOutputFile.WriteLine VbCrLf & ",DNS Changes"
For Each objNicConfig In colNicConfigs
objOutputFile.WriteLine VbCrLf & ",Network Adapter " & objNicConfig.Index _
& VbCrLf & ",," & objNicConfig.Description & VbCrLf & VbCrLf & _
",,Attempting to make changes in DNS configuration ..."
If (Not(IsNull(strDNSHostName))) And (Not(IsEmpty(strDNSHostName))) Then
intEnableDNS = objNicConfig.EnableDNS(strDNSHostName, strDNSDomain, _
arrDNSServerSearchOrder, arrDNSDomainSuffixSearchOrder)
If intEnableDNS = 0 Then
objOutputFile.WriteLine ",,Assigned new hostname."
If (Not(IsNull(strDNSDomain))) And (Not(IsEmpty(strDNSDomain))) Then
objOutputFile.WriteLine ",,Assigned new domain."
Else
objOutputFile.WriteLine ",,No new domain listed in input."
End If
If (Not(IsNull(arrDNSServerSearchOrder(0)))) And _
(Not(IsEmpty(arrDNSServerSearchOrder(0)))) Then
objOutputFile.WriteLine ",,Assigned new DNS server search order."
Else
objOutputFile.WriteLine ",,No new DNS server search order " & _
"listed in input."
End If
If (Not(IsNull(arrDNSDomainSuffixSearchOrder(0)))) And _
(Not(IsEmpty(arrDNSDomainSuffixSearchOrder(0)))) Then
objOutputFile.WriteLine ",,Assigned new DNS domain suffix " & _
"search order."
Else
objOutputFile.WriteLine ",,No new DNS domain suffix " & _
"search order listed in input."
End If
Else
objOutputFile.WriteLine ",,Unable to assign new hostname or enable DNS."
End If
Else
objOutputFile.WriteLine ",,No new hostname listed in input."
If (Not(IsNull(strDNSDomain))) And (Not(IsEmpty(strDNSDomain))) Then
intSetDomain = objNicConfig.SetDNSDomain(strDNSDomain)
If intSetDomain = 0 Then
objOutputFile.WriteLine ",,Assigned new domain."
Else
objOutputFile.WriteLine ",,Unable to assign new domain."
End If
Else
objOutputFile.WriteLine ",,No new DNS domain listed in input."
End If
If (Not(IsNull(arrDNSServerSearchOrder(0)))) And _
(Not(IsEmpty(arrDNSServerSearchOrder(0)))) Then
intSetDNSServers = objNicConfig.SetDNSServerSearchOrder _
(strDNSServerSearchOrder)
If intSetDNSServers = 0 Then
objOutputFile.WriteLine ",,Assigned new DNS server search order."
Else
objOutputFile.WriteLine ",,Unable to assign new DNS server " & _
"search order."
End If
Else
objOutputFile.WriteLine ",,No new DNS server search order " & _
"listed in input."
End If
If (Not(IsNull(arrDNSDomainSuffixSearchOrder(0)))) And _
(Not(IsEmpty(arrDNSDomainSuffixSearchOrder(0)))) Then
intSetDomainSuffixes = objNicConfig.SetDNSSuffixSearchOrder _
(arrDNSDomainSuffixSearchOrder)
If intSetDomainSuffixes = 0 Then
objOutputFile.WriteLine ",,Assigned new DNS domain " & _
"suffix search order."
Else
objOutputFile.WriteLine ",,Unable to assign new DNS domain " & _
"suffix search order."
End If
Else
objOutputFile.WriteLine ",,No new DNS domain suffix search order " & _
"listed in input."
End If
End If
If (Not(IsNull(blnFullDNSRegistrationEnabled))) And _
(Not(IsEmpty(blnFullDNSRegistrationEnabled))) Then
intSetDynamicReg = objNicConfig.SetDynamicDNSRegistration _
(blnFullDNSRegistrationEnabled, blnDomainDNSRegistrationEnabled)
If intSetDynamicReg = 0 Then
objOutputFile.WriteLine ",,Enabled dynamic DNS registration."
Else
objOutputFile.WriteLine ",,Unable to enable dynamic DNS registration."
End If
Else
objOutputFile.WriteLine ",,No dynamic DNS registration settings " & _
"listed in input."
End If
Next
End Sub
'******************************************************************************
Function SetNetbios
Set colNicConfigs = objWMIService.ExecQuery _
("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")
objOutputFile.WriteLine ",,NetBIOS Changes" & VbCrLf
For Each objNicConfig in colNicConfigs
intNetBIOS = objNicConfig.TcpipNetbiosOptions
If intNetBIOS = intNetbiosTcpip Then
objOutputFile.WriteLine ",,NetBIOS Over TCI/IP already set to " & _
"desired value."
SetNetbios = True
Else
objOutputFile.WriteLine ",,Attempting to set NetBIOS Over TCI/IP value."
intSetNetBIOS = objNicConfig.SetTCPIPNetBIOS(intNetbiosTcpip)
If intSetNetBIOS = 0 Then
objOutputFile.WriteLine ",,Successfully set NetBIOS over TCP/IP value."
SetNetbios = True
Else
objOutputFile.WriteLine ",,Unable to set NetBIOS Over TCI/IP value."
SetNetbios = False
End If
End If
Next
End Function
'******************************************************************************
Function SetWins
Set objNicConf = objWMIService.Get("Win32_NetworkAdapterConfiguration")
objOutputFile.WriteLine VbCrLf & ",,WINS Changes" & VbCrLf & VbCrLf & _
",,Attempting to enable WINS ..."
intEnableWINS = objNicConf.EnableWINS(blnDNSEnabledForWINSResolution, _
blnWINSEnableLMHostsLookup, strWINSHostLookupFile, strWINSScopeID)
If intEnableWINS = 0 Then
objOutputFile.WriteLine ",,Successfully enabled WINS on all network " & _
"adapters."
Else
objOutputFile.WriteLine ",,Unable to enable WINS."
End If
objOutputFile.WriteLine ",,Attempting to set WINS primary and " & _
"secondary servers ..."
intSetWINSServer = objNicConf.SetWINSServer(strWINSPrimaryServer, _
strWINSSecondaryServer)
If intSetWINSServer = 0 Then
objOutputFile.WriteLine ",,Successfully set WINS servers."
Else
objOutputFile.WriteLine ",,Unable to set WINS servers."
End If
If (errEnableWINS = 0) And (errSetWINSServer = 0) Then
SetWins = True
Else
SetWins = False
End If
End Function
'******************************************************************************
Function GetOsVer
Set colOperatingSystems = objWMIService.ExecQuery _
("Select * from Win32_OperatingSystem")
For Each objOperatingSystem In colOperatingSystems
GetOSVer = CSng(Left(objOperatingSystem.Version, 3))
Next
End Function
|