Run scheduled task only when connected to internet?

G

Guest

Guest
Archived from groups: microsoft.public.windowsxp.help_and_support (More info?)

Hello all,

I'd like to run a scheduled task (in win xp) only when my computer is
connected to the internet. I'm running eDNS, and it gives me a
hostname lookup error when it's run and not connected.

Is there a good way, other than just pinging a host, to determine if
i'm connected in a batch file perhaps?

Thanks,
Allie
 
G

Guest

Guest
Archived from groups: microsoft.public.windowsxp.help_and_support (More info?)

' launch.vbs--
' created by Torgeir Bakken
'--------------------8<----------------------
myApp = "C:\eDNS.EXE"
' set your own path and app name above
Set objShell = CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
arrNICstatus = GetIPAddresses
If UBound(arrNICstatus) > -1 Then
strProgPath = myApp
objShell.Run """" & strProgPath & """"
End If

Function GetIPAddresses()
'=====
' Based on a Michael Harris script, modified by Torgeir Bakken
'
' Returns array of IP Addresses as output
' by ipconfig or winipcfg...
'
' Win98/WinNT have ipconfig (Win95 doesn't)
' Win98/Win95 have winipcfg (WinNt doesn't)
'
' Note: The PPP Adapter (Dial Up Adapter) is
' excluded if not connected (IP address will be 0.0.0.0)
' and included if it is connected.
'=====
set sh = createobject("wscript.shell")
set fso = createobject("scripting.filesystemobject")
Set Env = sh.Environment("PROCESS")
if Env("OS") = "Windows_NT" then
workfile = Env("TEMP") & "\" & fso.gettempname
sh.run "%comspec% /c %systemroot%\system32\ipconfig.exe >" _
& Chr(34) & workfile & Chr(34), 0, true
else
'winipcfg in batch mode sends output to
'filename winipcfg.out
workfile = "winipcfg.out"
sh.run "winipcfg /batch" ,0,true
end if
set sh = nothing
set ts = fso.opentextfile(workfile)
data = split(ts.readall,vbcrlf)
ts.close
set ts = nothing
fso.deletefile workfile
set fso = nothing
arIPAddress = array()
index = -1
for n = 0 to ubound(data)
data(n) = replace(data(n),vbCr,"")
if instr(data(n),"IP Address") then
parts = split(data(n),":")
'if trim(parts(1)) <> "0.0.0.0" then
if instr(trim(parts(1)), "0.0.0.0") = 0 then
index = index + 1
ReDim Preserve arIPAddress(index)
arIPAddress(index)= trim(cstr(parts(1)))
end if
end if
next
GetIPAddresses = arIPAddress
End Function
' ---8< --end file cut here---
--
Mark L. Ferguson
FAQ for Windows Antispy http://www.geocities.com/marfer_mvp/FAQ_MSantispy.htm
<als_trash@hotmail.com> wrote in message news:1119482213.641783.145370@g43g2000cwa.googlegroups.com...
> Hello all,
>
> I'd like to run a scheduled task (in win xp) only when my computer is
> connected to the internet. I'm running eDNS, and it gives me a
> hostname lookup error when it's run and not connected.
>
> Is there a good way, other than just pinging a host, to determine if
> i'm connected in a batch file perhaps?
>
> Thanks,
> Allie
>