Announcement

Collapse
No announcement yet.

Multiple Command Prompt with Ping request with a single script

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Multiple Command Prompt with Ping request with a single script

    Hi,
    Please help me out to get a script to ping a multiple IP Address.
    That script should open a Multiple Command prompt with Ping Request.

    Thanking you in advance

    -PREM

  • #2
    Re: Multiple Command Prompt with Ping request with a single script

    Not sure what exactly you try to achieve.
    And, are you looking for a vbscript or batch or..? and in what way should it fetch the Ip-addreses that are going to be pinged?

    Here a batch
    Code:
    @echo off
    Set "newbox=start cmd /k"
    
    Set IPs=192.168.1.103 192.168.1.105 192.168.1.107 192.168.1.109
    
    For %%* in (%IPs%) do %newbox% PING.exe %%*
    \Rems

    This posting is provided "AS IS" with no warranties, and confers no rights.

    __________________

    ** Remember to give credit where credit's due **
    and leave Reputation Points for meaningful posts

    Comment


    • #3
      Re: Multiple Command Prompt with Ping request with a single script

      Hi Rems,
      Thanks for the Script file.
      Any format file is good for me. It is just to make sure all the network is fine or not.

      Please make the script you send, with an continous ping (-t)

      Which will be more greatfull.

      Thanks
      -PREM

      Comment


      • #4
        Re: Multiple Command Prompt with Ping request with a single script

        Hi Rems,
        I got the answer for the same.
        Here we go..,

        @echo off
        Set "newbox=start cmd /k"
        Set IPs=192.168.1.103 192.168.1.105 192.168.1.107 192.168.1.109
        For %%* in (%IPs%) do %newbox% PING.exe %%* -t

        Thank you Rems.

        Regards
        -PREM

        Comment


        • #5
          Re: Multiple Command Prompt with Ping request with a single script

          here is an other sample:
          Code:
          @echo off
          
          Set IPs=192.168.1.103, 192.168.1.105, 192.168.1.107, 192.168.1.109
          
          For %%* in (%IPs%) do START "%%*"/MIN/LOW COLOR 72^& PING.exe -t %%*

          \Rems

          This posting is provided "AS IS" with no warranties, and confers no rights.

          __________________

          ** Remember to give credit where credit's due **
          and leave Reputation Points for meaningful posts

          Comment


          • #6
            Re: Multiple Command Prompt with Ping request with a single script

            Hi Rems,
            Thanks for the answer and repy.

            Have a great day...!

            Thanks
            -PREM

            Comment


            • #7
              Re: Multiple Command Prompt with Ping request with a single script

              hi good day,

              facing 1 problem to save the -t pings to txt file
              try to play around with the script, however the log not saved, only the files created

              Referring to below script, i add > C:\%%*.txt at the end of the script, however the logs not saved. but the txt file for each of the listed IPs created in C drive.

              For %%* in (%IPs%) do %newbox% PING.exe %%* -t > c:\%%*.txt

              Comment


              • #8
                Re: Multiple Command Prompt with Ping request with a single script

                Originally posted by easternC View Post
                hi good day,

                facing 1 problem to save the -t pings to txt file
                try to play around with the script, however the log not saved, only the files created

                Referring to below script, i add > C:\%%*.txt at the end of the script, however the logs not saved. but the txt file for each of the listed IPs created in C drive.

                For %%* in (%IPs%) do %newbox% PING.exe %%* -t > c:\%%*.txt
                What your sample does is redirecting the output of the creation of a new box, it does not redirect the output of the statements in that newbox. Use parentheses to group or nest the statements after the &
                (like: %newbox% & (things happening in the box) ).
                Code:
                @echo off
                
                Set IPs=192.168.1.103, 192.168.1.105, 192.168.1.107, 192.168.1.109
                
                For %%* in (%IPs%) do call:pings %%* 
                
                goto:-pings subroutine-
                :pings
                (Set newbox=START "%*"/MIN/LOW COLOR 72)
                %newbox%  ^&(^>"c:\%*.txt" PING.exe %* -t)
                exit /b 0
                :-pings end of subroutine-
                \Rems
                Last edited by Rems; 10th December 2009, 21:48.

                This posting is provided "AS IS" with no warranties, and confers no rights.

                __________________

                ** Remember to give credit where credit's due **
                and leave Reputation Points for meaningful posts

                Comment


                • #9
                  Hi Rems,
                  I do not know about writing a bat file scrip , but every day I have to do monitoring network instead of a server. so I need to ping ip from 1 to 255 and from multiple subnets (My office has many branches & has multiple subnet). Can you help me make a bat file to do that, similar your scrip
                  Echo off Set "newbox=start cmd /k" Set IPs=192.168.1.103 192.168.1.105 192.168.1.107 192.168.1.109 For %%* in (%IPs%) do %newbox% PING.exe %%* Thanking you Regards Handam

                  Comment


                  • #10
                    Hello Handam,

                    Here is an example.
                    Three network-ids of 3 octets have been defined in this batch. For the last octet a range from 1 to 255 is used to construct IPv4 addresses.


                    Code:
                    @goto:begin of batch
                    
                    :pinging subroutine
                    For %%n in (%NetID%) do For /L %%h in (1,1,255) do PING.exe -n 1 %%n.%%h | find /i "ttl="
                    exit /b 0
                    
                    :begin of batch
                    Echo off
                    Set "NetID=192.168.1, 192.168.2, 192.168.3, 192.168.4"
                    > "pingresult.txt" call:pinging

                    This posting is provided "AS IS" with no warranties, and confers no rights.

                    __________________

                    ** Remember to give credit where credit's due **
                    and leave Reputation Points for meaningful posts

                    Comment


                    • #11
                      Hello Rems,

                      I am wanting to run this same batch file, but name each command prompt differently. I was trying to set two variables, one for IPs and one for title but can't seem to figure it out. Can you just use this same format, but name like 192.168.1.103 Desktop, 192.168.1.105 Firewall, etc

                      title= Firewall will name the command prompt Firewall, but I can't figure out how to incorporate that into this batch..

                      Echo off
                      Set "newbox=start cmd /k"

                      Set IPs=192.168.1.103 192.168.1.105 192.168.1.107 192.168.1.109

                      For %%* in (%IPs%) do %newbox% PING.exe %%*
                      Last edited by nicborde; 13th January 2017, 22:34.

                      Comment

                      Working...
                      X