.bat file, batch coding simple variable use


  1. Posts : 614
    Microsoft Windows 7 Ultimate 64-bit 7601 Multiprocessor Free Service Pack 1
       #1

    .bat file, batch coding simple variable use


    Code:
    @echo off
    color C
    SET IPaddress=0
    set /p IPaddress=Please enter the destination Ip Address:
    color A
    ping IPaddress
    pause
    okay, so i want the IPaddress variable to be used as the ipaddress to be pinged. When i run this, it is ineffective. Can someone teach me as why and how to properly code this?

    Actually i just figured out how to reference the variable with modulus/percentage symbols.
    %IPaddress%
      My Computer


  2. Posts : 10,485
    W7 Pro SP1 64bit
       #2

    Skylais said:
    ~~~
    Actually i just figured out how to reference the variable with modulus/percentage symbols.
    %IPaddress%
    Does this mean that you no longer need help?

    You might also want to make the batch file loop back to the start.
      My Computer


  3. Posts : 614
    Microsoft Windows 7 Ultimate 64-bit 7601 Multiprocessor Free Service Pack 1
    Thread Starter
       #3

    Actually do you mind showing me a basis on such a loop. Also if you know anywhere i could learn this simple type of batch coding, could you please link me to it
      My Computer


  4. Posts : 10,485
    W7 Pro SP1 64bit
       #4

    Here is a loop that I use:

    Code:
    :start
    ipconfig/all
    pause
    goto start
    For the ping batch file in your post, you might also want to tell the user how to enable quick edit so that they can quickly paste the IP address in... as opposed to typing it in or using the slower/default paste. Right click on the title bar of an open cmd window - then select properties - and look around.

    Try this website:
    Getting started with batch files

    edit: there is not a space between ipconfig and the switch /all.
    That space is optional. I tend not to put it there.
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 10:45.
Find Us