-2

I'm looking for some help. I would like to have a simple vbs that will check if there is a live connection. I have found some insight searching here, but the answers seem to be to specific to the questions asked and I am not sure if I could break them up to work for me.

I have found

How to launch vbs script after internet connection is detected in windows xp?

which would almost be a good start, but I'm not looking for a looping function

Also

Check network connection with VBScript

But it honestly looks intimating.

The vbs I would like to have would run silently (dim object shell kind of thing) and it will end up in the startup folder. I would like to check if a live internet connection is going (maybe ping a site) and if so then do something, else quit on startup. It will self delete once it has connected to internet and continued the installer.

Michael Lake
  • 11
  • 1
  • 4
  • Maybe this works for you? [Windows Task Scheduler: Trigger an Event When Internet Connects/Disconnects](https://www.groovypost.com/howto/automatically-run-script-on-internet-connect-network-connection-drop/) – Tomalak Jul 01 '18 at 03:59
  • SO is not a place where other people write code for you. Please try your hands at something first, *then* ask a question when you can't get something in your code to work the way you expected. – Ansgar Wiechers Jul 01 '18 at 09:55
  • Thanks for pushing me to find the answer. Just needed time to think about what I was looking for. I now know what I need to do next. – Michael Lake Jul 04 '18 at 07:20

1 Answers1

0

Found a way to get it working. And I just changed the "If PINGFlag then" to open a website linking to file to download, and Else to do other functions. Already tested. Works.

set WshShell = CreateObject("WScript.Shell") 

WshShell.run ("%COMSPEC% /c ipconfig  /release"), 0, true
WshShell.run ("%COMSPEC% /c ipconfig  /renew"), 0, true

PINGFlag = Not CBool(WshShell.run("ping -n 1 www.google.com",0,True))
If PINGFlag Then
    MsgBox "ip release/renew was successful."
Else
    MsgBox "ip release/renew was not successful"
End If
Michael Lake
  • 11
  • 1
  • 4