The script must be running on the target PC. Have it started from the Startup folder, Run key, RunOnce key, etc.

The script acts as a service/monitor to detect a new network connection.