PINTO1927 Posted November 18, 2016 Share Posted November 18, 2016 Hello guys, you can know, through a msgbox, if the connectivity of your computer is set to DHCP or static? Thank's Link to comment Share on other sites More sharing options...
JohnOne Posted November 18, 2016 Share Posted November 18, 2016 Probably a wmi way, but off top of head you can parse output from ipconfig /all AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted November 18, 2016 Moderators Share Posted November 18, 2016 Local $oWMI, $oNICs $oWMI = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2") If IsObj($oWMI) Then $oNICs = $oWMI.ExecQuery("Select * From Win32_NetworkAdapterConfiguration") If IsObj($oNICs) Then For $sNIC In $oNICs ConsoleWrite("For " & $sNIC.Description & ": " & $sNIC.DHCPEnabled & @CRLF) Next Else ConsoleWrite("Unable to pull NIC info from WMI" & @CRLF) EndIf Else ConsoleWrite("Unable to connect to WMI" & @CRLF) EndIf "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
PINTO1927 Posted November 18, 2016 Author Share Posted November 18, 2016 (edited) Thank's JLogan3o13, if you wanted to take the only dates of the network card? Thank's Edited November 18, 2016 by PINTO1927 Link to comment Share on other sites More sharing options...
PINTO1927 Posted November 18, 2016 Author Share Posted November 18, 2016 This can be corrected? $objWMI = ObjGet("winmgmts:\\.\root\cimv2") $collection = $objWMI.ExecQuery("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE") For $obj In $collection If $obj.DHCPEnabled = -1 Then $DHCPStatus = "TRUE" ConsoleWrite($DHCPStatus) Else $DHCPStatus = "FALSE" ConsoleWrite($DHCPStatus) EndIf Next Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted November 18, 2016 Moderators Share Posted November 18, 2016 I'm not sure what you mean by "dates of the network card"? But if you're looking for just the physical NIC for example you could do something like this: Local $oWMI, $oNICs $oWMI = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2") If IsObj($oWMI) Then $oNICs = $oWMI.ExecQuery("Select * From Win32_NetworkAdapterConfiguration") If IsObj($oNICs) Then For $sNIC In $oNICs If StringInStr($sNIC.Caption, "Ethernet") Then ConsoleWrite("For " & $sNIC.Caption & ": " & $sNIC.DHCPEnabled & @CRLF) Next Else ConsoleWrite("Unable to pull NIC info from WMI" & @CRLF) EndIf Else ConsoleWrite("Unable to connect to WMI" & @CRLF) EndIf There are a myriad of other ways to go about it, like $sNIC.IPAddress, etc. I suggest you search the forum for Scriptomatic to see what options are open to you. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
PINTO1927 Posted November 18, 2016 Author Share Posted November 18, 2016 Ok JLogan3o13, Thank's Link to comment Share on other sites More sharing options...
jguinch Posted November 18, 2016 Share Posted November 18, 2016 Local $oWMI = ObjGet("winmgmts:root\CIMV2") Local $oDHCP = $oWMI.ExecQuery("Select * from WIN32_NetworkAdapterConfiguration Where IPEnabled = True And DHCPEnabled = True") MsgBox(0, "", "Computer is set to " & ($oDHCP.Count ? "DHCP" : "Static" ) ) Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted November 18, 2016 Moderators Share Posted November 18, 2016 The only problem I can see with that approach (and it is admittedly a less common occurrence) is a dual-homed machine with different settings. I've run into it a couple of times at different companies. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
jguinch Posted November 18, 2016 Share Posted November 18, 2016 You're right. Usually, In my corporate network, I make the difference by checking the Ip address subnet, the default gateway or the IP address of the DHCP Server. BTW, the computer can be connecter with both ethernet and wireless connection... Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
RestrictedUser Posted May 20, 2019 Share Posted May 20, 2019 @JLogan3o13, How can i Get just this IP in below picture that we connect to RDP? I want to run the script in RDP too... i don't want use @IPAddress macros or _GetIP(), because in some of my RDPs i get wrong IP Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now