Link to home
Start Free TrialLog in
Avatar of llarava
llaravaFlag for Afghanistan

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.Network")

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("SELECT * FROM Win32_NetworkAdapterConfiguration 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("Select * 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.FileSystemObject")
strPath = "C:\temp"
strFullName = objFSO.BuildPath(strPath, strDomain &"-"& strName &"-"& StrPC & ".txt")
Set objFile = objFSO.CreateTextFile(strFullName, ForWriting, True)

objFile.Write strPC & vbCrLf
objFile.Write mess & vbCrLf
objFile.Write strText


objFile.Close
SOLUTION
Avatar of chandru_sol
chandru_sol
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Avatar of RobSampson
RobSampson
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial