Jump to content

Running .exe file automatically....


Recommended Posts

Posted

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?

Cheers

Phil.


Posted

Perhaps if you used a batch file or script file to verify ping response from the server and wait until the server pings back.

Posted

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.

Posted (edited)
@echo off
echo Waiting for an internet connection...

:TRYAGAIN

ping -w 1000 -n 1 internet.com>NUL
if errorlevel 1 GOTO TRYAGAIN
if errorlevel 0 GOTO OK

:OK
notepad.exe

Edited by jcarle
Posted

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.

Posted

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 off

rem echo Waiting for an internet connection...

RASDIAL "D-Link Internet Connection" "username" "password"

:PING

echo Trying to connect....

PING -w 1000 -n 1 172.16.1.70 | find "TTL=" && echo Connection made......

if errorlevel 1 goto PING

echo PC is now connected

echo Running .EXE file....

"C:\Program Files\Test\.EXE File"

:END

Posted

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).

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...