batch script to open website

DON'T post new tutorials here! Please use the "Pending Submissions" board so the staff can review them first.
Post Reply
User avatar
joebox
Fame ! Where are the chicks?!
Fame ! Where are the chicks?!
Posts: 213
Joined: 19 Mar 2012, 18:15
12
Contact:

batch script to open website

Post by joebox »

hello,

here we will create a batch file to open a website. First we must ping the website to see if it is running.

1. open notepad>save as>any file>mb.batch

2. in notepad type

Code: Select all

@echo off
ping www.suck-o.com

echo "suck-o is live"

pause

"%programfiles%\Mozilla Firefox\firefox.exe" 

"www.suck-o.com"

exit
now save and double click the file

1.with any batch file the first line should start with

Code: Select all

 @echo off
2. to see it the website is up and running use the

Code: Select all

 ping www.website.com 
3.we cannot go to a website that is not running so insert to pause the script and see if it received response from the ping. If not receiving response from website just click the x.

Code: Select all

 pause 

4. if you haven't clicked x yet that means the website will load so let's have a little fun here and type us a message using

Code: Select all

 echo "type message here" 
5. we must type the parameters for firefox and website using

Code: Select all

 
"%programfiles%\Mozilla Firefox\firefox.exe" "www.typeyourwebsite.com" 
6. when script is finished we will close the cmd window with

Code: Select all

exit
We just made a script to open a website at the click of a button. Have fun!

note: your directory for firefox.exe may be different so correct the path in line 5 of code if needed.
Last edited by joebox on 21 Apr 2012, 05:27, edited 2 times in total.
Award winning Unlimited Web Hosting
$1.81/month http://www.topratedhostservice.com
3 free domains | $100.00 Free advertising credits | Free Custom website design
Image

User avatar
ayu
Staff
Staff
Posts: 8109
Joined: 27 Aug 2005, 16:00
18
Contact:

Re: batch script to open website

Post by ayu »

I could not get this to work

Code: Select all

Pinging www.suck-o.com [85.25.150.199] with 32 bytes of data:
Reply from 85.25.150.199: bytes=32 time=24ms TTL=50
Reply from 85.25.150.199: bytes=32 time=25ms TTL=50
Reply from 85.25.150.199: bytes=32 time=24ms TTL=50
Reply from 85.25.150.199: bytes=32 time=24ms TTL=50

Ping statistics for 85.25.150.199:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 24ms, Maximum = 25ms, Average = 24ms
"suck-o is live"
Press any key to continue . . .
The system cannot find the path specified.
Press any key to continue . . .
Also, even though I understand the purpose of the pinging, I suggest that you use an if-statement in batch so that it actually checks if the answer was positive or not.
But yeah, maybe that is too advanced for such a tutorial.

Not saying that you have to fix the pinging, but do explain how to get it to work properly :-)
"The best place to hide a tree, is in a forest"

User avatar
joebox
Fame ! Where are the chicks?!
Fame ! Where are the chicks?!
Posts: 213
Joined: 19 Mar 2012, 18:15
12
Contact:

Re: batch script to open website

Post by joebox »

your problem is with the directory line which tells the computer what folder firefox.exe is in

I used

Code: Select all

"%programfiles%\Mozilla Firefox\firefox.exe"  

which is where my firefox.exe is located yours may be different if so, change the 5th line of code I provided by putting your proper directory path to your firefox.exe
Award winning Unlimited Web Hosting
$1.81/month http://www.topratedhostservice.com
3 free domains | $100.00 Free advertising credits | Free Custom website design
Image

User avatar
ayu
Staff
Staff
Posts: 8109
Joined: 27 Aug 2005, 16:00
18
Contact:

Re: batch script to open website

Post by ayu »

joebox wrote:your problem is with the directory line which tells the computer what folder firefox.exe is in

I used

Code: Select all

"%programfiles%\Mozilla Firefox\firefox.exe"  

which is where my firefox.exe is located yours may be different if so, change the 5th line of code I provided by putting your proper directory path to your firefox.exe
I am satisfied with that answer.
I will move your tut later today when I get back from work.
This will also give others a chance to comment it before it's moved :)

Good work
"The best place to hide a tree, is in a forest"

User avatar
joebox
Fame ! Where are the chicks?!
Fame ! Where are the chicks?!
Posts: 213
Joined: 19 Mar 2012, 18:15
12
Contact:

Re: batch script to open website

Post by joebox »

thank you, please enjoy.
Award winning Unlimited Web Hosting
$1.81/month http://www.topratedhostservice.com
3 free domains | $100.00 Free advertising credits | Free Custom website design
Image

Post Reply