Go Back   Computer Forums > General Computing > Software and Operating Systems
Click Here to Login
Join Computer forums Today


Reply
 
Thread Tools Search this Thread Display Modes
 
Old 08-20-2012, 07:18 PM   #1
In Runtime
 
WYSIWUG's Avatar
 
Join Date: Aug 2012
Location: New Zelaland
Posts: 381
Red face What is wrong with this Batch (.bat) file?

Hi Internet Land,


Can someone help me with this?

After I enter 192.168.0.1 and press enter, the batch file will go back to start, can someone point out what is wrong, and correct it? (Ignore all echo's)

Thanks


@echo off
color f4
cls
:start
echo ************************************************** ************************************************** **************************
echo Welcome To Auto Ping, Please enter the IP address or Domain Name on next screen, please use Ctrl+C to stop pinging at any time
echo ************************************************** ************************************************** **************************
pause
cls
set /p address=Enter IP address or Domain Name
ping %address% -t -l 1 -w 10000
pause
exit
:end
__________________

WYSIWUG is offline   Reply With Quote
Old 08-20-2012, 09:21 PM   #2
Fully Optimized
 
strollin's Avatar
 
Join Date: Mar 2011
Location: USA
Posts: 1,938
Default Re: What is wrong with this Batch (.bat) file?

Works OK for me.

Why do you have :start and :end anyway? They aren't needed.
__________________

strollin is offline   Reply With Quote
Old 08-21-2012, 04:44 PM   #3
In Runtime
 
WYSIWUG's Avatar
 
Join Date: Aug 2012
Location: New Zelaland
Posts: 381
Default Re: What is wrong with this Batch (.bat) file?

Quote:
Originally Posted by strollin View Post
Works OK for me.

Why do you have :start and :end anyway? They aren't needed.

So if I wanted to put a if errorlevel in somewere,

I.E. if errorlevel 2==goto start (or end)

---------- Post added at 08:44 AM ---------- Previous post was at 08:42 AM ----------

It's still going back to the start after I enter 192.168.0.1 and hit Enter, it wont even start a ping request.
WYSIWUG is offline   Reply With Quote
Old 08-21-2012, 05:55 PM   #4
Fully Optimized
 
strollin's Avatar
 
Join Date: Mar 2011
Location: USA
Posts: 1,938
Default Re: What is wrong with this Batch (.bat) file?

As I said, it works fine for me, not sure why it goes back to :start for you.

When you want to add the errorlevel checking, you will probably want the :start label to be immediately after @echo off and the :end label to be prior to exit.
strollin is offline   Reply With Quote
Old 08-22-2012, 08:06 PM   #5
In Runtime
 
WYSIWUG's Avatar
 
Join Date: Aug 2012
Location: New Zelaland
Posts: 381
Default Re: What is wrong with this Batch (.bat) file?

Oh man... It still wont work, it still jumps back to the start, I'll take out the switches in the ping command and see what happens, stand by...
WYSIWUG is offline   Reply With Quote
Old 08-23-2012, 09:40 PM   #6
In Runtime
 
WYSIWUG's Avatar
 
Join Date: Aug 2012
Location: New Zelaland
Posts: 381
Default Re: What is wrong with this Batch (.bat) file?

Quote:
Originally Posted by WYSIWUG View Post
Oh man... It still wont work, it still jumps back to the start, I'll take out the switches in the ping command and see what happens, stand by...

No still wont work! What The F#@$?! is wrong this batch file.
WYSIWUG is offline   Reply With Quote
Old 08-23-2012, 10:41 PM   #7
Site Team
 
celegorm's Avatar
 
Join Date: Sep 2006
Posts: 10,713
Send a message via AIM to celegorm
Default Re: What is wrong with this Batch (.bat) file?

Tell us more about the environment. What kind of computer are you running on and do you have admin rights?


Like Strollin the bat works just fine for me. There is nothing wrong with it.
__________________
"as a fanboy i refuse to admit it and will pull countless things out of my butt to disprove it"

Team Thelegorm! Total Kills: 21 (i iz in uor profile, editsing your sigz)
celegorm is offline   Reply With Quote
Old 08-24-2012, 12:00 AM   #8
Daemon Poster
 
Join Date: Jun 2005
Location: US
Posts: 676
Default Re: What is wrong with this Batch (.bat) file?

I did a bit of tinkering with your batch coding... (old batch file tinkerer here.).

Code:
Echo off
COLOR f4
CLS


ECHO ************************************************** ************************************************** **************************
ECHO Welcome To Auto Ping, Please enter the IP address or Domain Name on next screen, please use Ctrl+C to stop pinging at any time
ECHO ************************************************** ************************************************** **************************
PAUSE
CLS


ECHO Enter your IP address or Domain Name to ping.
:Input
SET /P address=
ping %address% -t -l 1 -w 10000
IF errorlevel 0 goto RedoIP

GOTO End

:RedoIP
ECHO There was an error in your IP or Domain address
PAUSE
GOTO IPinput

:IPinput
CLS
ECHO Please re-enter your Ip address or Domain Name to ping.
GOTO Input

:End
exit
I've tested and it works for me..
__________________
"The Crazy American says.."
A well regulated Militia, being necessary to the security of a free State,
the right of the people to keep and bear Arms, shall not be infringed.
BuzzStPoint is offline   Reply With Quote
Old 08-28-2012, 04:15 AM   #9
In Runtime
 
WYSIWUG's Avatar
 
Join Date: Aug 2012
Location: New Zelaland
Posts: 381
Default Re: What is wrong with this Batch (.bat) file?

The above code worked, thanks. I still am stumped as to why my first attempt was rubbish, I showed the code a batch programmer, he also said there was nothing wrong with my code, he also said it might be a setting in the Active Directory Group
Policy preventing the file from being able to execute. I dont have the rights on school computers to get into MMC at all.
WYSIWUG is offline   Reply With Quote
Old 08-28-2012, 10:47 PM   #10
Daemon Poster
 
Join Date: Jun 2005
Location: US
Posts: 676
Default Re: What is wrong with this Batch (.bat) file?

I think when you were putting in your errorlevel 2 was causing your loop.

added a few "goto"s and put in the errorlevel 0 to shoot it to the gotos.
__________________

__________________
"The Crazy American says.."
A well regulated Militia, being necessary to the security of a free State,
the right of the people to keep and bear Arms, shall not be infringed.
BuzzStPoint is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



All times are GMT -5. The time now is 04:31 PM.


Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0