WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: stanl on December 30, 2019, 12:38:44 PM

Title: Another quick COM Object to close out the decade
Post by: stanl on December 30, 2019, 12:38:44 PM
Code (WINBATCH) Select


;Winbatch 2019B - Enumerate Plug and Play
;Stan Littlefield December 30,2019
;=============================================================================
Oupnp = CreateObject('UPnP.UPnPDeviceFinder')
BoxOpen("Please Wait","Enumerating Plug and Play Devices")
devices = oupnp.FindByType("upnp:rootdevice", 0)


output=""
ForEach d in devices
   output=output:d.ModelName:" ":d.FriendlyName:" ":d.PresentationUrl:@LF
Next


BoxText("Devices":@LF:output)
Oupnp=0
TimeDelay(5)


Exit
Title: Re: Another quick COM Object to close out the decade
Post by: snowsnowsnow on December 31, 2019, 07:44:57 AM
Of course, a true pedant would point out that the 3rd decade of the 21st century doesn't start until a year from tomorrow.
Title: Re: Another quick COM Object to close out the decade
Post by: stanl on December 31, 2019, 12:27:56 PM
Quote from: snowsnowsnow on December 31, 2019, 07:44:57 AM
Of course, a true pedant would point out that the 3rd decade of the 21st century doesn't start until a year from tomorrow.


But according to Barbara Walters..   "This is 20/20"


and according to Google UPnP should be disabled as it is a security risk and your script is worthless.  Having received an email from Wyze about their database being hacked I was curious if our house cameras would show up when the script was run. They didn't and neither did the Honeywell Thermostat.
Title: Re: Another quick COM Object to close out the decade
Post by: stanl on January 04, 2020, 09:21:21 AM
I made a slight change FindByType("ssdp:all", 0) rather than FindByType("upnp:rootdevice", 0) and it appeared to duplicate 1 or 2 times the root devices. So, I further looked at the HasChildren property - my Router does, my Roku devices don't. Any suggestions how I might find out about the children
Code (WINBATCH) Select


;Winbatch 2019B - Enumerate Plug and Play
;Stan Littlefield December 30,2019
;=============================================================================
Oupnp = CreateObject('UPnP.UPnPDeviceFinder')
BoxOpen("Please Wait","Enumerating Plug and Play Devices")
;devices = oupnp.FindByType("upnp:rootdevice", 0)
devices = oupnp.FindByType("ssdp:all", 0)


output=""
ForEach d in devices
   ch=d.HasChildren
   If ch==-1
     ch="has children"
   Else
    ch="no children"
   Endif
   output=output:d.ModelName:" ":d.FriendlyName:" ":d.PresentationUrl:" ":ch:@LF
Next


BoxText("Devices":@LF:output)
Oupnp=0
TimeDelay(5)


Exit
Title: Re: Another quick COM Object to close out the decade
Post by: td on January 04, 2020, 10:41:03 AM
Other than the usual paranoia about IoT devices and a predilection to avoid them when possible and neuter them when it is not, I am not all that familiar with MSFT's take on the implementation of a UPnP query protocol.   About the only thing I can suggest is a look at the API documentation if you haven't already. 

https://docs.microsoft.com/en-us/windows/win32/api/_upnp/ (https://docs.microsoft.com/en-us/windows/win32/api/_upnp/)
Title: Re: Another quick COM Object to close out the decade
Post by: stanl on January 04, 2020, 11:06:19 AM
I believe I addressed the concerns/paranoia in an earlier post. I think if the Object has children and the children or services is System.__ComObject then the children are a COM array but you have to invoke another function FindByUDN()... and that is pointless. Finding the root devices is enough. Since my Wyze cameras are PlugnPlay but not recognized I feel a little better - even though my email and router type were part of the recent hack.










[/size]
[/size]
Title: Re: Another quick COM Object to close out the decade
Post by: td on January 05, 2020, 09:23:08 AM
Not sure what previous post you are referring to.  I probably missed the obvious someplace along the way.  I guess my paranoia with regards to IoT is mostly related to things other than hacking although hacking is a legitimate concern.