WPI - ConnectedToInternet() question cannot get it to work
#1
Posted 07 October 2010 - 03:33 AM
http://www.msfn.org/...__1#entry805421
But it doesn't work.
I have tried using both
ConnectedToInternet() and !ConnectedToInternet()
ConnectedToInternet()="true", ConnectedToInternet(true) and ConnectedToInternet("true
")
do I need to enable something in WPI to get it to work? In wpi > settings > general > allow check for internet connection is checked.
When I use !ConnectedToInternet() in exclude the item becomes gray with internet access and without internet access. It is as if wpi don't see my internet as it doesn't make any difference. Hope you can help me out solving this issue.
Btw. great work with WPI its really an awesome work.
#2
Posted 07 October 2010 - 01:49 PM
Second, if is false, go into WPIScripts/api.js, near the top, uncomment the 2 internet check lines. Try again. I was having issues with it a while back.
#3
Posted 07 October 2010 - 03:36 PM
mritter, on 07 October 2010 - 01:49 PM, said:
it say's false
mritter, on 07 October 2010 - 01:49 PM, said:
after uncommenting
// if (AllowCheckForInternet) // CheckForInternet();
I get:
Internet Connection - true
But if I unplug my ethernet cable and start wpi again it still say's Internet Connection - true.
if it does make any difference, i'm running windows 7 x64.
This post has been edited by franner: 07 October 2010 - 03:47 PM
#4
Posted 07 October 2010 - 04:10 PM
Plug in cable, start WPI, check in Alt+G, unplug cable, hit F5, check again.
#5
Posted 08 October 2010 - 05:05 AM
Thanks for your help.
Unfortunately it didn't solve the issue. Not when moving the folder or try again elsewhere on the PC.
This post has been edited by franner: 08 October 2010 - 06:59 AM
#6
Posted 08 October 2010 - 06:58 AM
Then I tried disable internet - disable LAN, unplug cable so no connection on main pc and in my virtual machine all connection is disconnected.
I started all over. Downloaded fresh, and nothing have been changed by me.
Copy it to my virtual machine.
Then I start wpi - internet connection - true
go to options - features - "allow check for internet connection" - alt+G - internet - false. But now when I close wpi and start it again and alt+G - internet connection - true. Here it should have said false instead.
Then I try edit api.js as u mentioned.
where I replace
// if (AllowCheckForInternet) // CheckForInternet();
with this:
if (AllowCheckForInternet) CheckForInternet();
start WPI - internet connection - true
I don't see why it don't work on my main or in virtual machine. I have now tried different combinations but none seems to work everytime.
If it works internet connection should say false and not true.
I have tried in windows xp and windows 7. I have restarted my PC and virtual machine and that doesn't help either. Its strange that it doesn't work the way it should
This post has been edited by franner: 08 October 2010 - 07:28 AM
#7
Posted 11 October 2010 - 08:42 AM
I have tried on fresh install serial times now, with windows xp, windows 7 x32 and windows 7 x64. All have samme issue as mentioned above, maybe you can look into it or know a solution (I have tried what you said but it does not solve the issue unfortunately).
#8
Posted 11 October 2010 - 01:50 PM
ConnectedToInternet() and !ConnectedToInternet() are what you want to use.
#9
Posted 12 October 2010 - 12:19 AM
mritter, on 11 October 2010 - 01:50 PM, said:
ConnectedToInternet() and !ConnectedToInternet() are what you want to use.
That is correct, that is the way I understand it too.
in alt+G if true = online
in alt+G if false = offline
mritter, on 11 October 2010 - 01:50 PM, said:
WPI > options > features > "Allow check for Internet Connection".
This one needs to be checked right?
mritter, on 11 October 2010 - 01:50 PM, said:
correct
#10
Posted 12 October 2010 - 01:27 AM
function CheckForInternet()
{
position="network.js";
whatfunc="CheckForInternet()";
var oExec = WshShell.Exec('ping -n 1 74.25.155.99');
while (oExec.Status == 0)
Pause(0,100);
var Output = oExec.StdOut.ReadAll() + oExec.StdErr.ReadAll();
// if (Output.search("Reply from") > -1) // Not always in English???
if (Output.search("74.25.155.99:") > -1)
ConnToNet=true;
else
ConnToNet=false;
}
Parsing text is always error prone, especially when running on OS with different locales (languages & formats), and that the utils can sometimes yield unexpected error messages. But here it just blindly pings 74.25.155.99 (an arris status page that isn't guaranteed to always be up or anything), and checks ping's output for that same text ("74.25.155.99"), which will pretty much always be present on the very first line it outputs, regardless of the connection state, so it'll always return true.
Unless you absolutely must be compatible with the ancient Win2k and earlier, the Win32_PingStatus WMI class is a far better/more robust approach, i.e. something like this:
var seriesOfTubes = false;
var wmiSvc = GetObject("winmgmts:\\\\.\\root\\CIMV2");
var pingRes = wmiSvc.ExecQuery("Select * from Win32_PingStatus Where Address = 'google.com'");
var e = new Enumerator(pingRes);
for (; !e.atEnd(); e.moveNext()) {
var p = e.item();
if (p.StatusCode == 0)
seriesOfTubes = true;
}
WScript.Echo ((seriesoftubes) ? "We Has The Internets!" : ":(");
This just works, regardless of language/locale, and no unforeseen error messages will cause problems... so long as Google still exists.
#11
Posted 12 October 2010 - 02:37 AM
Could you explain which lines should be replaced in which files for this to work?
Thanks alot for your kindness to help and figuring this out. I am really greatful for both your help.
This post has been edited by franner: 12 October 2010 - 02:51 AM
#12
Posted 12 October 2010 - 08:15 AM
@Franner: I sent you a beta copy of v8.2.0. Let me know the results.
#13
Posted 12 October 2010 - 04:33 PM
franner, on 12 October 2010 - 02:37 AM, said:
Well, if you want a drop-in replacement, you could replace this tidbit from network.js
function CheckForInternet()
{
position="network.js";
whatfunc="CheckForInternet()";
var oExec = WshShell.Exec('ping -n 1 74.25.155.99');
while (oExec.Status == 0)
Pause(0,100);
var Output = oExec.StdOut.ReadAll() + oExec.StdErr.ReadAll();
// if (Output.search("Reply from") > -1) // Not always in English???
if (Output.search("74.25.155.99:") > -1)
ConnToNet=true;
else
ConnToNet=false;
}
by:
function CheckForInternet()
{
position="network.js";
whatfunc="CheckForInternet()";
ConnToNet=false;
var wmiSvc = GetObject("winmgmts:\\\\.\\root\\CIMV2");
var pingRes = wmiSvc.ExecQuery("Select * from Win32_PingStatus Where Address = 'google.com'");
var e = new Enumerator(pingRes);
for (; !e.atEnd(); e.moveNext()) {
var p = e.item();
if (p.StatusCode == 0)
ConnToNet=true;
}
}
Note: I have not tested this at all, so I would backup network.js first.
mritter, on 12 October 2010 - 08:15 AM, said:
You're welcome. Hopefully the bits above will work as-is. Either ways, I was wondering why you guys haven't setup a public repository for WPI (not sure if you're using a revision control at all). CodePlex has free Mercurial hosting (otherwise I believe sourceforge and google code also do). It's free, it works great, it's super fast, and it's easy to use (using TortoiseHG and VisualHG). One could've forked WPI (not in the traditional "forking" sense), cloned it locally, made their changes, committed their work and pushed to it, then sent you a pull request to let you know that this available (then you can opt to merge the changes with your version). In a few simple clicks you could have had these changes integrated in your latest development version (without giving a 3rd party write access to your repository). It would allow people to contribute fairly easily (I'm not saying there would necessarily be a lot of contributors though), easily get any version of any file, see what's changed, etc.
#14
Posted 13 October 2010 - 09:30 AM
In the end what solve the issue for me was the one provided by CoffeeFiend. It works and does the jobs thanks for pointing it out.
Unfortunately the method by mritter worked great on windows xp, vista and windows 7 x86. But on my windows 7 x64 it didn't work for me (but on mritter's windows 7 x64 it worked). I don't know why, but this method by CoffeeFiend worked on all editions I tried (windows 7 x86, x64, windowws xp and vista when I tested it). Thank you both nontheless for solving this issue you are great!
- ← 8.1.0 questions-can't highlight command line.
- Windows Post-Install Wizard (WPI)
- Network Clarification →



Help
Back to top









