Philster Posted April 19, 2007 Posted April 19, 2007 We use BGINFO on the PCs at work that runs at startup and sends PC information to a database on a remote server.The problem is that the PCs at our shops use ADSL modems to connect to our network. So when the PCs are switched on and BGINFO runs there is no IP address as the modem isn't connected.So, what I'd like to do is get it so when the modem connects, BGINFO is then run automatically.Is there a way of doing this, using possibly a script or batch file or some other method, that, for example, connects the modem then once the connection is made automatically runs the BGINFO executable?CheersPhil.
jcarle Posted April 19, 2007 Posted April 19, 2007 Perhaps if you used a batch file or script file to verify ping response from the server and wait until the server pings back.
Philster Posted April 19, 2007 Author Posted April 19, 2007 hi there, thanks for the reply.I'm sure you can now guess my next question....!What would the syntax be for the batch file so it waits until a ping has a reply before moving on and running my executable?Cheers,Phil.
jcarle Posted April 19, 2007 Posted April 19, 2007 (edited) @echo offecho Waiting for an internet connection...:TRYAGAINping -w 1000 -n 1 internet.com>NULif errorlevel 1 GOTO TRYAGAINif errorlevel 0 GOTO OK:OKnotepad.exe Edited April 19, 2007 by jcarle
Philster Posted April 19, 2007 Author Posted April 19, 2007 Brilliant, thanks for that, I have not done exactly what you said as I couldn't get it to work, but I used PING and then found 'TTL=' in the output and used errorlevel on that and it is now working as I wanted.However (there is ALWAYS a however!), the bit I thought would be the easiest, calling the internet link from the batch file, I cannot do.The dialup connection is an .lnk file and when I run this it opens a command prompt but then doesn't do a whole lot else (i.e. it doesn't open the Connection box to put in user name, password etc).Any clues?Phil.
Philster Posted April 19, 2007 Author Posted April 19, 2007 I cracked it. There is a command called RASDIAL that can be called from a batch file. My final script is below. If i want I can now put the batch file into the startup or call it from the registry at startup so they don't have to mess about with it (they are managers in charity shops, not massively IT literate!)@echo offrem echo Waiting for an internet connection...RASDIAL "D-Link Internet Connection" "username" "password":PINGecho Trying to connect....PING -w 1000 -n 1 172.16.1.70 | find "TTL=" && echo Connection made......if errorlevel 1 goto PINGecho PC is now connectedecho Running .EXE file...."C:\Program Files\Test\.EXE File":END
jcarle Posted April 19, 2007 Posted April 19, 2007 Nice work. It's amazing what batch files can accomplish sometimes.
Zxian Posted April 19, 2007 Posted April 19, 2007 Yup - Rasdial is a great little tool. I tried using it to automatically dial into my university's VPN servers when I connected to their network (somewhat like IBM's Access Connections does).
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now