pcjunki Posted May 27, 2011 Share Posted May 27, 2011 i'm tring to create a program that will ping my router, and if i do not get a response, it will execute another program here is my code ping ("192.168.1.10") if @error =1 Then ShellExecute("c:\myscript.vbs") Sleep(3000) then idealy i would like it to loop, starting all over please help, i've looked at all the examples on here, and i'm stumped Link to comment Share on other sites More sharing options...
November Posted May 27, 2011 Share Posted May 27, 2011 Hi there, Check While and Wend commands. Cheers Old Scriptology Visual Ping 1.8 - Mass Ping Program with export to txt delimited. Desktop 2 RGB and YMCK - Pick a color in the desktop and get the RGB and YMCK code. Desktop 2 RGB - Pick a color in the desktop and get the RGB code. ShootIT 1.0 - Screen Capture full and partial screen [font="'Arial Black';"]Remember Remember The Fifth of November.[/font] Link to comment Share on other sites More sharing options...
pcjunki Posted May 27, 2011 Author Share Posted May 27, 2011 ok, i have the looping down, ( i guess) but still need help with the pinging part While 1=1 ping ("172.16.3.26") if @error =1 Then ShellExecute("c:\myscript.vbs") Sleep(3000) WEnd Link to comment Share on other sites More sharing options...
wakillon Posted May 27, 2011 Share Posted May 27, 2011 While 1 Ping ("172.16.3.26") If @error =1 Then ShellExecuteWait("c:\myscript.vbs") Sleep(3000) WEnd You can probably convert your vbs script to AutoIt... AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
pcjunki Posted May 27, 2011 Author Share Posted May 27, 2011 While 1 Ping ("172.16.3.26") If @error =1 Then ShellExecuteWait("c:\myscript.vbs") Sleep(3000) WEnd You can probably convert your vbs script to AutoIt... i'm having problems with the pinging syntax..... Link to comment Share on other sites More sharing options...
pcjunki Posted May 27, 2011 Author Share Posted May 27, 2011 i'm having problems with the pinging syntax..... i got it to work While 1 Ping("192.168.1.1") If @error =1 Then ShellExecute("c:\myscript.vbs") Sleep(3000) WEnd Link to comment Share on other sites More sharing options...
Ghost21 Posted September 16, 2011 Share Posted September 16, 2011 (edited) ok so this is wat I got $var = "" msgbox(0,$device, $var & " ms." & " Before." ) Result --> window with pc01 then blank ms. Before. $var = Ping($device,10000) msgbox(0,$device,$var & " ms" & " After.") Result --> window with pc01 then 0 ms. After. IS that 0 correct ? How acurate is that ping command in AutoIT ??? If I ping in dos I seem to get a steady 4ms., 5ms or 6ms. I'm trapping for Error's now and I'm getting all Error 4 's even though it says the ping returned 0 This some NEW BUG?????? Edited September 16, 2011 by Ghost21 Link to comment Share on other sites More sharing options...
Ghost21 Posted September 19, 2011 Share Posted September 19, 2011 (edited) I hate to *BUMP* things but this stops my whole script from running because I can't trust the results coming back from Autoits ping can someone help me on this one..The strange part is this time I know its not me.. Well it could be me but I don't think so.. msgbox(0,$device,$ping)$ping = Ping($device,10000)msgbox(0,$device,$ping) Returns a $Device name and blank in the message box.. " Perfect ping has nothing in it.. "slight pause cause of the 10000 timeout just for testingReturns a $Device name and 0 in the message box.. " WTF something is messed up with ping..." HELP!!! Edited September 19, 2011 by Ghost21 Link to comment Share on other sites More sharing options...
BrewManNH Posted September 19, 2011 Share Posted September 19, 2011 When Ping can't reach the address, it returns 0, so if you get a 0 as a return, then Ping didn't find the address and nothing was returned. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator Link to comment Share on other sites More sharing options...
Ghost21 Posted September 19, 2011 Share Posted September 19, 2011 (edited) Well if I ping from dos at the exact same time it returns a ping..Which would make me think for that reason that it is a bug.. Edited September 19, 2011 by Ghost21 Link to comment Share on other sites More sharing options...
Ghost21 Posted September 19, 2011 Share Posted September 19, 2011 In a test script the code below runs fine.. Same with the Autoit Script ping. Inside the script when this is run it comes back like the ping is in the wrong syntax.. Any idea what could be effecting both pings inside my script... $device = "PC001" $Reply = "" $Testping = Run(@ComSpec & " /c " & 'ping.exe ' & $device & " -n 1 -w 500 " & '| find "Reply" ', @WindowsDir, @SW_SHOW, $STDOUT_CHILD) While ProcessExists($Testping) Sleep(10) $Reply &= StdoutRead($Testping) If @error Then ExitLoop WEnd $ReplySplit = StringSplit($Reply, " ") If $ReplySplit >= 6 Then $IP = StringTrimRight($ReplySplit[3], 1) $Ping = StringTrimLeft($ReplySplit[5], 5) EndIf MsgBox(0,"IP: " & $ip , "Ping: " & $ping) Link to comment Share on other sites More sharing options...
BrewManNH Posted September 19, 2011 Share Posted September 19, 2011 What's the error message you get when you run that script? If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator Link to comment Share on other sites More sharing options...
Ghost21 Posted September 19, 2011 Share Posted September 19, 2011 It returns the results of the dos output like you just typed ping and pushed enter. Link to comment Share on other sites More sharing options...
BrewManNH Posted September 19, 2011 Share Posted September 19, 2011 I'm not sure why it's not working for you, but I ran that exact script, except I changed the $device variable to a computer on my network, and I got a message box with the correct information. (Win 7 x86) If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator Link to comment Share on other sites More sharing options...
Ghost21 Posted September 19, 2011 Share Posted September 19, 2011 Win 7 x64 Ent. Link to comment Share on other sites More sharing options...
Ghost21 Posted September 19, 2011 Share Posted September 19, 2011 I wish you could see what autoit is putting in the dos window.. before it closes...then I can debug or somethign whats going on .. Link to comment Share on other sites More sharing options...
BrewManNH Posted September 19, 2011 Share Posted September 19, 2011 Use /k instead of /c after the @Comspec and it should keep the window open to allow you to see the command console. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator Link to comment Share on other sites More sharing options...
Ghost21 Posted September 19, 2011 Share Posted September 19, 2011 OK this is tottally screwed.. I got it working by doing this $Testping = Run(@ComSpec & " /c " & "ping -n 1 -w 500 PC001 | find ""Reply""", "", @SW_SHOW, $STDOUT_CHILD) That worked .. but the just $device doesn't.. even though right before it I did a msgbox(0,"",$device) and it showed the device name no problem.. $Testping = Run(@ComSpec & " /c " & "ping -n 1 -w 500 " & $Device & " | find ""Reply""", "", @SW_SHOW, $STDOUT_CHILD) Link to comment Share on other sites More sharing options...
Ghost21 Posted September 19, 2011 Share Posted September 19, 2011 The bigger question is why would a simple $ping = Ping($device,500) not work and a $ping = Ping("pc001",500) work no problem.. Link to comment Share on other sites More sharing options...
shornw Posted September 20, 2011 Share Posted September 20, 2011 I had similar issues with the Ping() command. I could ping a device from a CMD window and get replies, but the Ping() command returned fails every time. I never could get to the root of the problem. As it was part of a script to load balance, it was essential that I got reliable info so I ended up using :- Run(@ComSpec & " /c ping <devicename/IP>") which worked absolutely fine. It was really frustrating for quite a while [font='Comic Sans MS']Eagles may soar high but weasels dont get sucked into jet engines[/font] Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now