dkwokgs Posted February 22, 2004 Share Posted February 22, 2004 Hi there, Is there a way write a script to detect LAN connection to a server eg. 192.168.100.100 upon login loging on to the system and if server exist run the certain program,if not run another program? Regards Daniel Link to comment Share on other sites More sharing options...
Developers Jos Posted February 22, 2004 Developers Share Posted February 22, 2004 this is a v3 script that works for WinXP, for other WinOS you migth need to check the ping parameters: ; Run ping with count=1 and timeout = 1 second $rc = RunWait(@comspec & ' /c ping 192.168.100.100 -n 1 -w 1000','',@SW_HIDE) If $rc = 0 Then ; host exists Else ; host doesn't exists EndIf in ver2 something like this : (not tested) Run, %COMSPEC% /c ping 192.168.100.100 -n 1 -w 1000 ,,hide IfEqual, ERRORLEVEL, 0, Goto, HostExists ; host doesn't exist ..... exit ; HostExists: ; host exists ..... exit SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Beastmaster Posted February 22, 2004 Share Posted February 22, 2004 Ping the server, redirect response to a file, check the file content.If server has replied, use net use to connect to the serverIf he's not active, do something different (eg. wait before you check'm again) ...-----Ping:RunWait, %COMSPEC% /C PING www.hiddensoft.com > %TEMP%\PingResponse.txtSetEnv, ln, 3SetEnv, to, 0Check:FileReadLine, PingResp, %TEMP%\PingResponse.txt, %ln%IfInString, PingResp, Reply from, EnvAdd, to, 1EnvAdd, ln, 1IfLessOrEqual, ln, 7, Goto, CheckToBeOrNotToBe:IfEqual, to, 4, Goto, ConnectServerDown:Repeat, 60Sleep, 1000EndRepeatGoto, PingConnect:Run, %COMSPEC% /C net use ......----- Link to comment Share on other sites More sharing options...
ezzetabi Posted February 25, 2004 Share Posted February 25, 2004 (edited) My script for knowing if a computer is on or off. IfLess,0,1,exit,255 RunWait,%comspec% /c ping -n 1 -w 50 %1%>%temp%\ison.tmp,,hide FileReadLine,text, %temp%\ison.tmp, 7 RunWait,%comspec% /c del %temp%\ison.tmp,,hide IfNotInString,text,Ricevuti = 1,goto,off ;"Ricevuti" should be changed with the word that appear in your language. ;on exit,0 off: exit,1 Edited February 25, 2004 by ezzetabi Link to comment Share on other sites More sharing options...
dkwokgs Posted February 27, 2004 Author Share Posted February 27, 2004 Thanks a lot for the info. Cheers Daniel Link to comment Share on other sites More sharing options...
Recommended Posts