Friday, 20 May 2011

Delay .bat script

Windows is a strange thing, especially at startup. Things are just loading and loading:) Sometimes strange things happen if a program in startup folder starts before everything is loaded. There is simple way to delay your program to start with ping command.

Save bellow command to file and name give it an arbitrary name with bat extension. For example: run.bat

ping -w 1000 -n 10 localhost

 Create link to this file in windows startup folder and your program will start after it pings itself 10 times. Bellow I also copied explanation about ping command.

PING is used to test TCP/IP connectivity with another host and
gives information about the length of time test data takes to be sent to the
host and a reply received.
Its most basic use is as follows:

C:\ping IP address or hostname
Pinging with 32 bytes of data:

Reply from bytes=32 time=10ms TTL=252
Reply from bytes=32 time<10ms TTL=252
Reply from bytes=32 time<10ms TTL=252
Reply from bytes=32 time<10ms TTL=252

From the above you can see it send 32 bytes to host and each
time a reply was received in 10ms or less, this shows a good connection.
PING does have a number of option parameters to accomplish different

In Windows 2000 you can press Ctrl-Break when running the -t option for a
list of statisitics. Press Ctrl-C to actually stop the ping.
It can be useful to have a small batch file ping various hosts and terminal
servers at regular intervals to ensure all are still present (although there
are commercial software packages that do this). A simple command like:

C:\ping -f -n 1 -l 1
Pinging with 1 bytes of data:
Reply from bytes=1 time<10ms TTL=128
pings a host once with one byte of data.

You should be aware that PING works by sending ICMP echo packets and some routers etc may filter
these out meaning a PING will not work.

No comments:

Post a Comment