On a Windows machine, when you connect a device that appears as a 'mass storage device' to the computer, such as a flash disk, media player, phone, etc, it will automatically run software stored on the device, given two conditions. First is that Autoplay is enabled for the logical drive in question, ie the drive letter. This may not be the same assignment between sessions, if the user connects different devices, and is unlikely to be the same between computers. The second is that the device needs an
autorun.inf file that specifies what program(s) to run.
This means that it's a simple matter to do this on a Windows-based machine if Autoplay is enabled (it's enabled by default, and many novice users don't change this). Once your program is executed, it can do pretty much whatever it wants, including obtaining the local IP address(es) assigned to the computer. This might be different from the external IP address, if the machine is behind a router, but you can determine that easily enough by parsing the returned data from sites such as
whatismyip.org. Alternatively, you can query the router if this is supported, but a direct method probably isn't on many home routers, which leaves parsing a mess of generated HTML for the address, and it will be different for each router model.
Once you have the IP address(es) you need, it's a simple matter to send the data to your destination.