Jump to content

Running .exe file automatically....


Philster

Recommended Posts

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.

Link to comment
Share on other sites


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.

Link to comment
Share on other sites

@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
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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