Share via

How to create a .bat file for quick access to network troubleshooting commands

Anonymous
2012-02-13T03:00:51+00:00

@echo OFF

color 0a

cls

:Start4

echo                    º  1. IP Config /All                 

echo                    º  2. NETSTAT                        

echo                    º  3. NSLOOKUP                       

echo                    º  4. Telnet                         

echo                    º  5. add IP ADDRESS                 

echo                    º  6. add gateway                    

echo                    º  7. add dns                        

echo                    º  8. NBTSTATS                       

echo                    º  9. ARP Table                      

echo                    º  10.Launch Host FIle               

echo                    º  11.Check Internet connectivity    

echo                    º  12.IP to Mac address              

echo                    º  13.Refresh Network Settings       

echo                    º  14.Network Connections.cpl        

echo                    º  15.Network Setup Wizard.cpl       

echo                    º 16. Return to Main Menu            

echo                    º 17. Exit                           

echo.

echo.

echo Enter Choice.

SET /P variable=

IF %variable%==17 GOTO exit

IF %variable%==16 GOTO menu

IF %variable%==15 GOTO ncpa

IF %variable%==14 GOTO netsetup

IF %variable%==13 GOTO refresh

IF %variable%==12 GOTO IPMac

IF %variable%==11 GOTO connectivity

IF %variable%==10 GOTO HostFile

IF %variable%==9 GOTO ARPA

IF %variable%==8 GOTO NBTSTATS

IF %variable%==7 GOTO DNSAD

IF %variable%==6 GOTO GWAD

IF %variable%==5 GOTO IPAD

IF %variable%==4 GOTO Telnet

IF %variable%==3 GOTO NSLOOKUP

IF %variable%==2 GOTO NETSTAT

IF %variable%==1 GOTO IPSH

:IPSH

ipconfig /all

Echo Completed...

ECHO.

echo Press Enter to go to Network Functions script

echo.

pause > nul

GOTO Start4

:NETSTAT

start c:\windows\system32\netstat.exe

pause

goto Start4

:NSLOOKUP

start c:\windows\system32\nslookup.exe

pause

goto Start4

:Telnet

start c:\windows\system32\telnet.exe

pause

goto Start4

:IPAD

echo Enter IP address in dotted format [ex: 192.168.10.100] :

Set /P variable1=

echo Enter subnet mask in dotted format [ex: 255.255.25.0] :

Set /P variable2=

echo Enter the name of you network connection [ex: Local Area Connection, Lan] :

Set /P variable3=

netsh interface ip add address %variable3% %variable1% %variable2%

Echo Completed...

ECHO.

echo Press Enter to go to Network Functions script

echo.

pause > nul

GOTO Start4

:GWAD

echo Enter the name of you network connection [ex: Local Area Connection, Lan] :

Set /P variable3=

echo Enter gateway in dotted format [ex: 192.168.10.100] :

Set /P variable4=

netsh interface ip add address "%variable3%" gateway=%variable4% gwmetric=2

Echo Completed...

ECHO.

echo Press Enter to go to Network Functions script

echo.

pause > nul

GOTO Start4

:DNSAD

echo Enter the name of you network connection [ex: Local Area Connection, Lan] :

Set /P variable3=

echo Enter primary adns ddress in dotted format [ex: 10.168.115.105] :

Set /P variable5=

echo Enter secondary dns address in dotted format [ex: 10.168.115.105] :

Set /P variable6=

netsh interface ip add dns %varialbe3% %variable5%

netsh interface ip add dns %varialbe3% %variable6% index=2

echo.

Echo Completed...

ECHO.

echo Press Enter to go to Network Functions script

echo.

pause > nul

GOTO Start4

:NBTSTATS

@echo off

color 0a

cls

echo.

echo  NetBIOS Connection Table

echo.

start /wait nbtstat.exe

cd\

nbtstat -S

Echo Completed...

pause

cd\

nbtstat -c

Echo Completed...

pause

nbtstat -n

Echo Completed...

pause

cd\

nbtstat -r

Echo Completed...

pause

cd\

nbtstat -s

Echo Completed...

pause

echo.

Echo Completed...

ECHO.

echo Press Enter to go to Network Functions script

echo.

pause > nul

GOTO Start4

:ARPA

@echo off

color 0a

cls

echo.

echo  ARP Table

echo.

start /wait arp.exe

cd\

arp -a

echo.

Echo Completed...

ECHO.

echo Press Enter to go to Network Functions script

echo.

pause > nul

GOTO Start4

:HostFile

@echo off

color 0a

cls

start /wait notepad c:\windows\system32\drivers\etc\hosts

echo.

Echo Completed...

ECHO.

echo Press Enter to go to Network Functions script

echo.

pause > nul

GOTO Start4

:connectivity

@echo off

ECHO Checking connection, please wait...

PING -n 1 www.google.com|find "Reply from " >NUL

IF NOT ERRORLEVEL 1 goto :SUCCESS

IF     ERRORLEVEL 1 goto :TRYAGAIN

:TRYAGAIN

ECHO FAILURE!

ECHO Let me try a bit more, please wait...

@echo off

PING -n 3 www.google.com|find "Reply from " >NUL

IF NOT ERRORLEVEL 1 goto :SUCCESS2

IF     ERRORLEVEL 1 goto :TRYIP

:TRYIP

ECHO FAILURE!

ECHO Checking DNS...

ECHO Lets try by IP address...

@echo off

ping -n 1 216.239.37.99|find "Reply from " >NUL

IF NOT ERRORLEVEL 1 goto :SUCCESSDNS

IF     ERRORLEVEL 1 goto :TRYROUTER

:TRYROUTER

ECHO FAILURE!

ECHO Lets try pinging the router....

ping -n 2 192.168.1.1|find "Reply from " >NUL

IF NOT ERRORLEVEL 1 goto :ROUTERSUCCESS

IF     ERRORLEVEL 1 goto :NETDOWN

:ROUTERSUCCESS

ECHO It appears that you can reach the router, but internet is unreachable.

goto :FAILURE

:NETDOWN

ECHO FAILURE!

ECHO It appears that you having network issues, the router cannot be reached.

goto :FAILURE

:SUCCESSDNS

ECHO It appears that you are having DNS issues.

goto :FAILURE

:SUCCESS

ECHO You have an active Internet connection

pause

goto END

:SUCCESS2

ECHO You have an active internet connection but some packet loss was detected.

pause

goto :END

:FAILURE

ECHO You do not have an active Internet connection

pause

goto :END

:END

Echo Completed...

ECHO.

echo Press Enter to go to menu

echo.

pause > nul

goto GOTO Start4

:IPMac

@Echo off

cls

COLOR 22

set ip= %1

if /i "%1" == "?" goto help

if /i "%1" == "/?" goto help

if /i "%1" == "-h" goto help

if /i "%1" == "--help" goto help

if /i "%1" == "/h" goto help

if /i "%1" == "" (goto start

)else goto auto

:start

cls

echo.

echo.

echo.

echo Clearing ARP Cache . . .

netsh interface ip delete arpcache

echo Enter IP address of remote computer:

set /p ip=

if %ip% == exit goto end

if %ip% == quit goto end

for %%i in (%ip%) do (ping -n 1 %%i > NUL

if errorlevel 1 goto fail

cls

echo.

echo IP Address MAC Address Type

echo ___________________________________________________

echo.

arp -a | findstr "%%i"

goto eof

)

echo.

:auto

ping -n 1 %1 > NUL

if errorlevel 1 goto fail2

cls

echo.

echo IP Address MAC Address Type

echo ___________________________________________________

echo.

arp -a | findstr "%1"

echo.

goto end

:fail

echo.

cls

echo.

echo Host not found, or not alive

echo.

goto eof

:fail2

echo.

cls

echo.

echo Host not found, or not alive

echo.

goto end

:eof

echo.

pause

goto end

:help

@echo off

echo.

echo DESCRIPTION:

echo Gets the MAC address for a remote computer, given it's IP address.

echo.

echo USAGE:

echo getmac [ip_address]

echo.

echo PARAMETERS:

echo To use interactively, run getMAC with no parameters.

echo.

echo EXAMPLE:

echo.

echo getmac 192.168.1.1

:end

Echo Completed...

ECHO.

echo Press Enter to go to menu

echo.

pause > nul

GOTO Start4

:refresh

@ECHO OFF

color 0a

cls

Echo.

Echo IP release

Echo Flush DNS

Echo IP renew

Echo.

ipconfig /release

ipconfig /flushdns

ipconfig /renew

Echo.

Echo Completed...

ECHO.

echo Press Enter to go to menu

echo.

pause > nul

GOTO Start4

:ncpa

@ECHO OFF

color 0a

cls

Echo.

echo Network Connections:

control.exe ncpa.cpl

pause

echo Netork connection option2:

control.exe netconnections

Echo.

Echo Completed...

ECHO.

echo Press Enter to go to menu

echo.

pause > nul

GOTO Start4

:netsetup

@ECHO OFF

color 0a

cls

Echo.

echo Network Setup Wizard:

control.exe netsetup.cpl

Echo.

Echo Completed...

ECHO.

echo Press Enter to go to menu

echo.

pause > nul

GOTO Start4

:menu

Echo Completed...

ECHO.

echo Press Enter to go to menu

echo.

pause > nul

goto menu

:exit

Echo Completed...

ECHO.

echo Press Enter to go to menu

echo.

pause > nul

goto menu

Windows for home | Previous Windows versions | Files, folders, and storage

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

  1. Anonymous
    2012-02-13T22:34:01+00:00

    Hi,  

    Your Windows 7 question is more complex than what is typically answered in the Microsoft Answers forums. It is better suited for the developer audience on MSDN. Please post your question in the MSDN Forum. You can follow the link to post your question:

    http://social.msdn.microsoft.com/Forums/en-US/vsx/threads

    Hope this information is helpful.

    0 comments No comments

0 additional answers

Sort by: Most helpful