Please help me with Batch, need manual input required see description

Page 1 of 2 12 LastLast

  1. Posts : 7
    windows 7 pro 64bit
       #1

    Please help me with Batch, need manual input required see description


    Hi there,
    I am trying to create a batch file which will use the command nbtstat-a and then request the IP of the user within the same line (e.g. nbtstat-a *please enter the target IP to lookup*) to look up the machine name of a computer on the network, the only problem is that i dont know how to make it so that the first part is automatically filled out (nbtstat -a) then the user has to input the IP address to continue.
    Please could anyone help?
    Thanks :) Much Appreciated
      My Computer


  2. Posts : 784
    Linux Mint 17 Cinnamon | Win 7 Ult x64
       #2

    Hi,

    Welcome to Seven Forums

    To concatenate commands use the & symbol.

    For example, Command A & Command B

    Try this.

    set /p id="Enter IP Address: " & nbtstat -a %id%

    Tanya
      My Computer


  3. Posts : 7
    windows 7 pro 64bit
    Thread Starter
       #3

    Brilliant! thankyou so much
      My Computer


  4. Posts : 7
    windows 7 pro 64bit
    Thread Starter
       #4

    I have managed to get the command working when I ping an IP address however when I do nbtstat -a it just loops back to the start and I am unable to do the lookup, I have tried doing timeouts and goto command but it still doesn't seem to work! what am i doing wrong?
      My Computer


  5. Posts : 784
    Linux Mint 17 Cinnamon | Win 7 Ult x64
       #5

    Can you post your batch file, please
      My Computer


  6. Posts : 7
    windows 7 pro 64bit
    Thread Starter
       #6

    this is what I have so far:

    @ECHO OFF
    set /p "id=Please enter an IP address: "
    cls
    Ping %ID%
    nbtstat -a %id%

    it successfully pings however it doesn't do the nbtstat look up it just jumps back "please enter an IP address"
      My Computer


  7. Posts : 784
    Linux Mint 17 Cinnamon | Win 7 Ult x64
       #7

    Ok, that looks fine to me.
    And indeed, it runs perfectly for me.
    Here's the output.

    Code:
    Pinging 192.168.1.2 with 32 bytes of data:
    Reply from 192.168.1.2: bytes=32 time=2ms TTL=128
    Reply from 192.168.1.2: bytes=32 time=1ms TTL=128
    Reply from 192.168.1.2: bytes=32 time=2ms TTL=128
    Reply from 192.168.1.2: bytes=32 time=2ms TTL=128
    
    Ping statistics for 192.168.1.2:
        Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
    Approximate round trip times in milli-seconds:
        Minimum = 1ms, Maximum = 2ms, Average = 1ms
    
    Local Area Connection:
    Node IpAddress: [192.168.1.2] Scope Id: []
    
               NetBIOS Remote Machine Name Table
    
           Name               Type         Status
        ---------------------------------------------
        WORKGROUP      <00>  GROUP       Registered
        TANYA-PC       <00>  UNIQUE      Registered
        TANYA-PC       <20>  UNIQUE      Registered
        WORKGROUP      <1E>  GROUP       Registered
        WORKGROUP      <1D>  UNIQUE      Registered
        ..__MSBROWSE__.<01>  GROUP       Registered
    
        MAC Address = BC-5F-F4-45-5C-B8
    I ran it from my desktop, then from my C:\ drive, then as a scheduled task. It worked perfectly every time. I even ran it from within another cmd file, and then "called" it from within another cmd file. Works every time.

    So, how are you running it?

    Tanya
      My Computer


  8. Posts : 7
    windows 7 pro 64bit
    Thread Starter
       #8

    Ive tried it from desktop and c drive and it still loops
    http://postimg.org/image/en98ot5jz/ thats whats happening
    I have full admin permission so thats not the problem either
      My Computer


  9. Posts : 784
    Linux Mint 17 Cinnamon | Win 7 Ult x64
       #9

    Hi,

    Well, I've spent the last day trying to recreate your problem. Tried it on XP, Windows 7, Windows 8 and 8.1. I tried it on a standard user account, and an administrator account. No matter what I do I can't recreate the problem you're having. This is really bizarre

    I'll keep digging and trying different things....

    Meanwhile, if any other knowledgeable people are passing by hopefully they will chime in..

    btw, should probably add "Set id=" (minus the quotes) as the last line just to clean up after. That will delete the environment variable.



    Tanya
      My Computer


  10. Posts : 7
    windows 7 pro 64bit
    Thread Starter
       #10

    Hi Tanya, I really appreciate that you have been helping and tried so many ways to get around the issue!
    ive had the thought, would the issue be occurring due to the fact that im on a domain?
    will add that line now:)
    Thanks again for all the help!
    -Lewis
      My Computer


 
Page 1 of 2 12 LastLast

  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 01:22.
Find Us