llarava
asked on
I need a script that checks if the IP of the system is 192.X.X.X
I need to modify this part of the script
With item
For Each strIPAddress In .IPAddress
mess = mess & " " & strIPAddress & VbCrLf
Next
If the IP for the NIC on the desktop is 192.X.X.X the script is going to go ahead and do the rest of the code of the script.
If the the IP is not a 192.X.X.X the script is going to stop and exit.
Const ForWriting = 2
Dim strComputer
Dim objWMIService
Dim colItems
Set objNetwork = CreateObject("Wscript.Netw ork")
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
strName = objNetwork.UserName
strDomain = objNetwork.UserDomain
strPC = objNetwork.ComputerName
'strIP = GetRow("IP Address", objNetwork.IPAddress)
strUser = strDomain & "\" & strName
strText = strUser & vbCrLf
Set wmiService = GetObject("winmgmts:\\" & ComputerName)
Set wmiItems = wmiService.ExecQuery("SELE CT * FROM Win32_NetworkAdapterConfig uration WHERE IPEnabled = True")
For Each item In wmiItems
With item
For Each strIPAddress In .IPAddress
mess = mess & " " & strIPAddress & VbCrLf
Next
end with
next
Set colPrinters = objWMIService.ExecQuery("S elect * From Win32_Printer")
For Each objPrinter in colPrinters
If Not objPrinter.Attributes And 64 Then
strText = strText & objPrinter.Name & vbCrLf
End If
Next
Set objFSO = CreateObject("Scripting.Fi leSystemOb ject")
strPath = "C:\temp"
strFullName = objFSO.BuildPath(strPath, strDomain &"-"& strName &"-"& StrPC & ".txt")
Set objFile = objFSO.CreateTextFile(strF ullName, ForWriting, True)
objFile.Write strPC & vbCrLf
objFile.Write mess & vbCrLf
objFile.Write strText
objFile.Close
With item
For Each strIPAddress In .IPAddress
mess = mess & " " & strIPAddress & VbCrLf
Next
If the IP for the NIC on the desktop is 192.X.X.X the script is going to go ahead and do the rest of the code of the script.
If the the IP is not a 192.X.X.X the script is going to stop and exit.
Const ForWriting = 2
Dim strComputer
Dim objWMIService
Dim colItems
Set objNetwork = CreateObject("Wscript.Netw
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
strName = objNetwork.UserName
strDomain = objNetwork.UserDomain
strPC = objNetwork.ComputerName
'strIP = GetRow("IP Address", objNetwork.IPAddress)
strUser = strDomain & "\" & strName
strText = strUser & vbCrLf
Set wmiService = GetObject("winmgmts:\\" & ComputerName)
Set wmiItems = wmiService.ExecQuery("SELE
For Each item In wmiItems
With item
For Each strIPAddress In .IPAddress
mess = mess & " " & strIPAddress & VbCrLf
Next
end with
next
Set colPrinters = objWMIService.ExecQuery("S
For Each objPrinter in colPrinters
If Not objPrinter.Attributes And 64 Then
strText = strText & objPrinter.Name & vbCrLf
End If
Next
Set objFSO = CreateObject("Scripting.Fi
strPath = "C:\temp"
strFullName = objFSO.BuildPath(strPath, strDomain &"-"& strName &"-"& StrPC & ".txt")
Set objFile = objFSO.CreateTextFile(strF
objFile.Write strPC & vbCrLf
objFile.Write mess & vbCrLf
objFile.Write strText
objFile.Close
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.