PAdocIT
asked on
VBScript help
I would like to modify the following VB script to check chassis type and if the chassis type is a laptop I would like the script to end. If else I want the script to continue on and add the DNS. Can anyone help me out or point me in the right direction, preferably the former as I really no nothing about VB. :)
Thanks,
Mike
Thanks,
Mike
strComputer = "."
'wscript.echo strComputer
'strComputer = InputBox("Enter the Machine Name you want to modify")
On Error Resume Next
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colNetCards = objWMIService.ExecQuery _
("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")
'change arrDNSServers to reflect values for your environment
For Each objNetCard in colNetCards
arrDNSServers = Array("0.0.0.1","0.0.0.2","0.0.0.3")
objNetCard.SetDNSServerSearchOrder(arrDNSServers)
Next
If Err.Number <> 0 Then
'wscript.echo err.number
'If err.number = 462 then
'strStatus = "Error-COULD NOT CONNECT," &strComputer
'ElseIf err.number = 451 then
'strStatus = "Error-ACCESS DENIED," &strComputer
'Else
strStatus = "Error," & strComputer
'End If
Else
strStatus = "Success," & strComputer
End If
w.writeline strStatus
Err.Clear
On Error Goto 0
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
OK, don't worry about the log file then. Remove this line
w.writeline strStatus
Wow, no DHCP...that must be a nightmare....I hope this script helps.
Rob.
w.writeline strStatus
Wow, no DHCP...that must be a nightmare....I hope this script helps.
Rob.
ASKER
Thanks Rob. Worked like a charm.
Very good. Thanks for the grade.
Regards,
Rob.
Regards,
Rob.
ASKER
Anyway a little background since my original post was a bit vague.