batch help

Status
Not open for further replies.

ms-dos707

Solid State Member
Messages
19
Well i am very new to coding .bat files
but i decided to make a useful file
when i open it it closes about 0.5 a second later
i dont know what wrong but here is my code
sorry if the top is a little messed up thats just because i copied and pasted

Code:
@echo off
:menu
cls
echo    IIIIIIIIIII    MMMMM       AAAAA              H    H    AAAAA  CCCCC      K      K    E EEE   RRRR            
echo          | |         M    M   M        A   A    A              HHH    A   A    A  C                 K K         E  E        R   R    
echo     IIIIIIIIII     M    M   M        A         A              H    H    A         A  CCCCC      K     K     E EEE    R      R
Pause
echo  ______________________________________________________________________________
echo |                Welcome to: Imahacker4ever's Network info                                                                   |   
echo |                                                                                                                                                           |      
echo |                                        The place where you can get all your Tcp-IP, current connections  \/       |   
echo |        Dns, gateway, static ip, and instructions on how to do stuff                                                      |
echo _______________________________________________________________________________ 
pause 
echo OPTIONS:
echo Press A for your basic IP info ex. gateway (which is your routers ip address) , subnet mask,  IP address (which is your computers ip address)
echo.
echo Press B for your Complete IP info 
echo.
echo Press C for Your browser to start ip and take u to a website that will show you your real IP address
echo Note: IPchicken is totally safe it will not steal your ip. 
echo  Note 2: This will only work if you have the firefox or internet explorer Browsers
echo.
echo Press D to learn how to change your ip
echo.
echo Press E To see all your current connections
echo. 
echo Press F to learm the syntax of the "netstat" command so you can learn how to put it to good use
echo.
echo Press G to learn the syntax of the "ipconfig" command so you can learn how to put it to good use
echo.
echo Press X to Exit out of this program.
echo.
echo.
echo.
set /p network=Option: 
if %network%==A ipbasic
if %network%==a goto ipbasic
if %network%==B goto ipcomplex
if %network%==b goto ipcomplex
if %network%==C goto c4chicken
if %network%==c goto c4chicken
if %network%==D goto changeme
if %network%==d goto changeme
if %network%==E goto cc
if %network%==e goto cc
if %network%==F goto syntaxnetstat
if %network%==f goto syntaxnetstat
if %network%==G goto syntaxipconfig
if %network%==g goto syntaxipconfig
if %network%==X goto exit
if %network%==x goto exit
if %network#==* goto error
goto error
:ipbasic 
ipconfig
pause
goto menu
:ipcomplex
ipconfig/all
pause 
goto menu
:c4chicken
start iexplore.exe ipchicken.com
start firefox.exe ipchicken.com
goto menu
:changeme
echo Hi
echo Today I will be helping you change your IP...
Pause
cls
echo If this doesnt work Well.... Don't get mad at me!
pause 
cls
echo Oh... and this won't do this all for you... But ill help ypu with the last part.
pause 
echo First i'm going to do something called "RELEASE", this will "release" all of your current internet and network connectons
echo but it won't harm anything! Note: You WILL loose your internet and network connections for a couple seconds...
echo So save all open work...
pause
ipconfig/release
echo First step done but...
pause 
echo next step is to unplug your router/routers, turn them off 
:cc
netstat -a
pause
goto menu
:syntaxnetstat
netstat ?
pause 
goto menu
:syntaxipconfig
ipconfig ?
pause
goto menu
:exit
exit
:error
echo Invalid command. Please make sure the commands you type
echo in are correct.
pause
cls
goto menu
 
pipes dont agree directly after echos

It was erroring out at line 5 (first pipe), took that out and then it errored elsewhere. I took out your entire "Title" (lines 4 through 13) and the batch file paused at a option like you wanted.

just by browsing over your batch file quickly, you may want to download crimson editor .. it's free and handy. Also, launch a shell first rather than placing your file name in the run prompt... that way it wont close upon exit, unless you call "exit"

IMO Creating useful batch files takes time... worry about the "meat and potatoes" of what you want to do first rather than waste time on a "title screen". Menus are great, just all the stuff above it... lol

EDIT: Another tip... using a /I switch right after "If" allows you to rule out case sensitivity...
So:

Code:
if %network%==F goto syntaxnetstat
if %network%==f goto syntaxnetstat

becomes

Code:
if /I %network%==F goto syntaxnetstat

It covers lower and upper cases
 
No no no... of course you dont sound rude... I totally understand.

Ok, the 5th line down had two pipes "|" <<< these things. Just remove those two first...

Then lines 9, 10, 11 and 12 had a pipe "|" right after the "echo" command. Remove those four. Then resave it and you are good to go.

As for opening a shell, I meant... Start > Run > type "cmd" and hit enter. Navigate to where your file is and then launch it from there.
 
wait one more thing is there any way i can code it so that it will open when i click the file?
 
I meant that, while you were "troubleshooting" you could open a shell prompt and run it from there. That way you could see errors without it closing out on you.

The way you are doing it is fine, it will be able ot be doubleclicked to run.
 
Thank you i figured out the shell thingy
so when i do this next thing (pressing enter at the option menu)
it exits out
when i went into the shell it says ipbasic not expected at this time
its sapose to say invalid choice or whatever

again sorry if the top and the bottom is messed up

heres the code
Code:
time/t
echo working 
echo       ---------------------------------------------------------------------
echo      I IIIII MMMM    AAAAA    H   H     AAAAA  CCCCC  K  K    EEEE  RRRR    I
echo      I  I I  M M M     A___A    HHHH    A___A   C         K K     EE     R__R    I
echo      I IIIII M M M     A     A    H   H     A    A   CCCCC  K  K    EEEE  R   R    I
echo       ---------------------------------------------------------------------
echo.
echo     ---------------------------------------------------------------------------
echo    I             Welcome to: Imahacker4ever's Network info                                  I
echo.   I                                                                                                         I
echo    I     The place where you can get all your Tcp-IP, current connections  \/       I
echo    I     Dns, gateway, static ip, and instructions on how to do stuff                    I
echo     ---------------------------------------------------------------------------
echo. 
echo OPTIONS:
echo Press A for your basic IP info ex. gateway (which is your routers ip address) , subnet mask,  IP address (which is your computers ip address)
echo.
echo Press B for your Complete IP info 
echo.
echo Press C for Your browser to start ip and take u to a website that will show you your real IP address
echo Note: IPchicken is totally safe it will not steal your ip. 
echo  Note 2: This will only work if you have the firefox or internet explorer Browsers
echo.
echo Press D to learn how to change your ip
echo.
echo Press E To see all your current connections
echo. 
echo Press F to learm the syntax of the "netstat" command so you can learn how to put it to good use
echo.
echo Press G to learn the syntax of the "ipconfig" command so you can learn how to put it to good use
echo.
echo Press X to Exit out of this program.
echo.
echo.
echo.
set /p network=Option: 
if /I %network%==A ipbasic
if /I %network%==B goto ipcomplex
if /I %network%==C goto c4chicken
if /I %network%==D goto changeme
if /I %network%==E goto cc
if /I %network%==F goto syntaxnetstat
if /I %network%==G goto syntaxipconfig
if /I %network%==X goto exit
if %network#==* goto error
goto error
:ipbasic 
ipconfig
pause
goto menu
:ipcomplex
ipconfig/all
pause 
goto menu
:c4chicken
start iexplore.exe ipchicken.com
start firefox.exe ipchicken.com
goto menu
:changeme
echo Hi
echo Today I will be helping you change your IP...
Pause
echo.
echo If this doesnt work Well.... Don't get mad at me!
pause 
echo.
echo Oh... and this won't do this all for you... But ill help ypu with the last part.
pause 
echo First i'm going to do something called "RELEASE", this will "release" all of your current internet and network connectons
echo but it won't harm anything! Note: You WILL loose your internet and network connections for a couple seconds...
echo So save all open work...
pause
ipconfig/release
echo First step done but...
pause 
echo next step is to unplug your router and plug them back in
echo okay the next step is to restart your computer you can choose to now (with the option menu below) or to go to exit or go to the menu 
goto restartmenu
:cc
netstat -a
pause
goto menu
:syntaxnetstat
netstat ?
pause 
goto menu
:syntaxipconfig
ipconfig ?
pause
goto menu
:restart 
shutdown -r
:exit
exit
:error
echo Invalid command. Please make sure the commands you type
echo in are correct.
pause
cls
goto menu
:restartmenu
echo  ------------------------------------------------------------------
echo I                                                                                              I
echo I  Welcome to Imahacker4ever's Restart menu!!!                               I
echo I                                                                                              I
echo I                                                                                              I
echo I        Options:  R  To finish the process of changing your ip               I
echo I        and restarting your pc                                                        I
echo I                                                                                             I
echo I M to clear the screen go back to the menu and you can manually     I
echo I                restart the comp                                                      I
echo I                                                                                            I
echo I       X to exit this program                                                        I
echo  ------------------------------------------------------------------
pause
set /p network=Option: 
if /I %network%==R goto restart
if /I %network%==M goto clsmenu
if /I %network%==X goto exit
if %network#==* goto error
goto error
:restart 
shutdown -r
goto exit
:clsmenu
cls
goto menu
 
Status
Not open for further replies.
Back
Top Bottom