There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
access audio avg avg 8 bios blue screen boot bsod computer connection cpu crash css dell desktop dma driver drivers dvd email error excel explorer firefox firefox 3 freeze gimp graphics hard drive hardware hijackthis hjt install internet internet explorer itunes keyboard laptop macro malware monitor motherboard network networking outlook outlook 2003 outlook 2007 outlook express pio problem problems router seo server slow sound sp3 spyware trojan usb video virtumonde virus vista vundo windows windows vista windows xp winxp wireless
DOS/PDA/Other
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Operating Systems > DOS/PDA/Other >
Batch File Question


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

 
Thread Tools
NeroMorte's Avatar
Junior Member with 5 posts.
 
Join Date: Oct 2007
22-Oct-2007, 08:07 PM #1
Exclamation Batch File Question
Hi Below is a Batch to Change your IP Address. Works good to change the IP

But i want it to Display Current IP Save that Data into IP_OLD Var and Chnage IP then Display OLD IP to NEW IP

So The Problem is the Follow:

Quote:
IP Address. . . . . . . . . . . . : 7X.2XX.9X.2XX
IP Address. . . . . . . . . . . . : fe30::711:5bff:fe84:5960%4
IP Address. . . . . . . . . . . . : fe30::ffff:ffff:fffd%5
IP Address. . . . . . . . . . . . : 2102:44ed:23c9::47ed:63c9
IP Address. . . . . . . . . . . . : fe80::51fe:31.237.19.241%2
IT Display's Last Line "fe80::51fe:31.237.19.241%2" I want it to Display only the Top Line the Real IP. Same is Happening with the MAC Address.

One other Question is there Better Way to Do Message Box Other then VBS

Below is The Batch File Code to Change IP.

ChangeIP.bat
Quote:
:Change IP Batch File
:Written by NeroMorte

COLOR 0C

@ECHO off
:Below are the choices.

set PcK1=Yes
set PcK2=No

:Gobal Settings
SET TEMP1=TEMP_IP
SET TEMP2=TEMP_MAC
SET IP_OLD=''

:Choices
cls
ECHO.Change IP Batch File
ECHO.Batch File Coded by NeroMorte
ECHO.


ECHO.
ECHO.
ECHO.Please select Yes / No from the following:
ECHO.
ECHO. 1. %PcK1%
ECHO. 2. %PcK2%

ECHO.
set /p PcKs=Pick Number or Type Yes To Continue or No to Exit?


ECHO.
ECHO.

REM ##########################################################
REM NOT : perform the command if the condition is false.
REM == : perform the command if the two strings are equal.
REM /I : Do a case Insensitive string comparison.
REM EQU : equal
REM NEQ : not equal
REM LSS : less than <
REM LEQ : less than or equal <=
REM GTR : greater than >
REM GEQ : greater than or equal >=
REM ##########################################################

IF NOT '%PcKs%' EQU '' set TheChoice=%PcKs%

IF %PcKs% EQU Yes set TheChoice=%PcKs%
IF %PcKs% EQU No set TheChoice=%PcKs%
IF %PcKs% EQU 1 set TheChoice=%PcKs%
IF %PcKs% EQU 2 set TheChoice=%PcKs%

IF %TheChoice% EQU Yes GOTO One
IF %TheChoice% EQU No GOTO Two
IF %TheChoice% EQU 1 GOTO One
IF %TheChoice% EQU 2 GOTO Two

ECHO "%PcKs%" is not valid Entry please try again.
ECHO.
Pause
GOTO Choices


:One
ECHO YOU HAVE PICKED NUMBER ONE
ECHO.
@ECHO off

:: Get the current IP address
@IPCONFIG /ALL | FIND /I "IP Address" > %TEMP1%
@FOR /F "tokens=1-6 delims=,:. " %%i in (%TEMP1%) do (

@SET IP=%%k %%l %%m %%n

)

:: Get MAC Address
@IPCONFIG /ALL | FIND /I "Physical Address" > %TEMP2%
@FOR /F "tokens=1-6 delims=,:. " %%o in (%TEMP2%) do (

@SET MAC=%%q

)

@cls
GOTO ChangeIP
:END

:ChangeIP
ECHO.
ECHO. Username: %username%
ECHO. IP Address: %IP%
ECHO. MAC Address: %MAC%
ECHO. PC Name: %Computername%
ECHO. Time/Date Requested IP Change: %TIME%/%Date%
ECHO.
ECHO.
ECHO. ... Changing IP Please Wait ...
ECHO.
Set IP_OLD=%IP%
Pause
@ECHO off
ipconfig /flushdns

ipconfig /release
@cls
ECHO. ... Changing IP Please Wait ...
netsh interface ip set address "Local Area Connection 2" static 107.70.125.50 255.0.0.0 24.8.128.1 1

ipconfig /renew
@cls
ECHO. ... Changing IP Please Wait ...
netsh interface ip set address "Local Area Connection 2" dhcp
netsh interface ip set DNS "Local Area Connection 2" dhcp
netsh interface ip set WINS "Local Area Connection 2" dhcp
@cls

:: Get the current IP address
@IPCONFIG /ALL | FIND /I "IP Address" > %TEMP1%
@FOR /F "tokens=1-6 delims=,:. " %%i in (%TEMP1%) do (

@SET IP=%%k %%l %%m %%n

)

:: Get MAC Address
@IPCONFIG /ALL | FIND /I "Physical Address" > %TEMP2%
@FOR /F "tokens=1-6 delims=,:. " %%o in (%TEMP2%) do (

@SET MAC=%%q

)

ECHO. MsgBox "- New IP Address: %IP% -" + vbcr + "- OLD IP Address: %IP_OLD% -" ,64 + 4096,"%username%'s IP Changed Successful" > msgbox.vbs
Start msgbox.vbs
::goto ExitBatch
:END

:Error
ECHO Please Try again!
GOTO Choices
:END

:Two
ECHO YOU HAVE PICKED NUMBER TWO PRESS ANY KEY TO EXIT.
Pause
@cls
EXIT
:END

:Error
ECHO Please Try again!
GOTO Choices
:END

:ExitBatch
:: Clear the Temp file

@ECHO off

echo. > %TEMP1%
echo. > %TEMP2%
@cls
ECHO. ... Please Wait Clearing Temp Files ...

ECHO Y | DEL %TEMP1% /S /Q
ECHO Y | DEL %TEMP2% /S /Q
@cls
ECHO. ... Please Wait Clearing Temp Files ...

@Echo off
@Echo =-_-=-_-=-_-=-_-=-_-=-_-=-_-=-_-=-_-=-_-=-_-=-_-=-_-=
@Echo =! !=
@Echo =! Exiting Thanks for Using NeroMorte IP Changer!! !=
@Echo =! !=
@Echo =! !=
@Echo =! !=
@echo =! IP-Changer Window will disappear in 10 seconds! !=
@Echo =-_-=-_-=-_-=-_-=-_-=-_-=-_-=-_-=-_-=-_-=-_-=-_-=-_-=

@ping -n 10 127.0.0.1 > nul

::@pause
EXIT

:END
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

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 Off
Refbacks are Off

You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 03:27 PM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.