I search to use the methode EnableStatic for change the IPAddress
on the NetAdapter..
using the class Win32_NetworkAdapterConfiguration
this error appair
any idea ?-2147024809
One or more arguments are invalid. Possibly a numerical overflow or too many nested objects, -if so, try splitting your method call into two or more subcalls.
Code: Select all
;/////////////////////////////////////////////////////////////////////////////////
;***COMate***  COM automation through iDispatch.
;*===========
;*
;*WMI demo - renew IP addresses. By SFSxOI.
;/////////////////////////////////////////////////////////////////////////////////
IncludePath "..\..\"
XIncludeFile "COMate.pbi"
XIncludeFile "VariantHelper_Include.pb"
Define.COMateObject objWMIService, objNetCard 
colNetCards.COMateEnumObject 
Define *IPAddress.VARIANT,*ConnectID.VARIANT, *varIP.VARIANT
  *sa.SafeArray
strComputer.s = "." 
objWMIService = COMate_GetObject("winmgmts:\\" + strComputer + "\root\cimv2", "") 
If objWMIService 
  colNetCards = objWMIService\CreateEnumeration("ExecQuery('Select IPAddress from Win32_NetworkAdapterConfiguration')")  
  If colNetCards 
  
    objNetCard = colNetCards\GetNextObject() 
    While objNetCard 
    ;Debug objNetCard\GetstringProperty("IPAddress")
    *IPAddress= objNetCard\GetvariantProperty("IPAddress") 
        If *IPAddress\vt <> #VT_NULL
          *sa = *IPAddress\parray
          For i = saLBound(*sa) To saUBound(*sa)
            *varIP = SA_VARIANT(*sa, i)
            If *varIP\vt <> #VT_BSTR
              VariantChangeType_(*varIP, *varIP, 0, #VT_BSTR)
            EndIf
            sIPAddress.s= PeekS(*varIP\bstrVal, -1, #PB_Unicode)
            If sIPAddress="192.168.65.5"
            ;objNetCard\SetProperty("EnableStatic'(192.168.66.5,255.255.255.0)'") 
            objNetCard\SetProperty("EnableStatic($0027"+"192.168.66.5,255.255.255.0"+"$0027)") 
           Debug  COMate_GetLastErrorCode() 
           Debug COMate_GetLastErrorDescription() 
          EndIf
            VariantClear_(*varIP)
            
          Next
          saFreeSafeArray(*sa)
        EndIf
        VariantClear_(*IPAddress) : FreeMemory(*IPAddress)
        
      objNetCard\Invoke("RenewDHCPLease()") 
      objNetCard\Release() 
      objNetCard = colNetCards\GetNextObject() 
    Wend 
    colNetCards\Release() 
  EndIf 
  objWMIService\Release()  
Else
  MessageRequester("COMate - WMI demo", "Couldn't create the WMI scripting object!")
EndIf 
jpd



