Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Batch file to ping everyday and save in notepad  (Read 9871 times)

0 Members and 1 Guest are viewing this topic.

Akod

    Topic Starter


    Rookie

    • Certifications: List
    • Experience: Experienced
    • OS: Windows 7
    Batch file to ping everyday and save in notepad
    « on: September 10, 2014, 03:35:44 AM »
    Hello,

    Please i need to create a batch file to check whether a server is on everyday and save
    the results in a notepad folder on the desktop.

    Kindly assist me with this.

    Thanks in advance.


    foxidrive



      Specialist
    • Thanked: 268
    • Experience: Experienced
    • OS: Windows 8
    Re: Batch file to ping everyday and save in notepad
    « Reply #1 on: September 10, 2014, 05:15:51 AM »
    Do you have any code to start with?

    Akod

      Topic Starter


      Rookie

      • Certifications: List
      • Experience: Experienced
      • OS: Windows 7
      Re: Batch file to ping everyday and save in notepad
      « Reply #2 on: September 10, 2014, 05:25:09 AM »
      Please no code at the moment.

      foxidrive



        Specialist
      • Thanked: 268
      • Experience: Experienced
      • OS: Windows 8
      Re: Batch file to ping everyday and save in notepad
      « Reply #3 on: September 10, 2014, 05:29:14 AM »
      Please no code at the moment.

      ok.  Which server are you going to ping?  An internet server or a local server on the LAN?

      or do you have to do this for an assignment?

      Akod

        Topic Starter


        Rookie

        • Certifications: List
        • Experience: Experienced
        • OS: Windows 7
        Re: Batch file to ping everyday and save in notepad
        « Reply #4 on: September 10, 2014, 06:27:47 AM »
        A local server on LAN

        Squashman



          Specialist
        • Thanked: 134
        • Experience: Experienced
        • OS: Other
        Re: Batch file to ping everyday and save in notepad
        « Reply #5 on: September 10, 2014, 06:36:36 AM »
        Code: [Select]
        @echo off
        ping IPADDRESS >>"C:\path to\logfile.txt"
        Use Windows Task Scheduler to have it run every day at the time you want it to run.

        Akod

          Topic Starter


          Rookie

          • Certifications: List
          • Experience: Experienced
          • OS: Windows 7
          Re: Batch file to ping everyday and save in notepad
          « Reply #6 on: September 10, 2014, 06:44:57 AM »
          Please how can i make it name itself after the current date so that it will not replace each other?

          Squashman



            Specialist
          • Thanked: 134
          • Experience: Experienced
          • OS: Other
          Re: Batch file to ping everyday and save in notepad
          « Reply #7 on: September 10, 2014, 06:46:44 AM »
          Please explain in better detail what you are trying to do.  Please list examples of what you want.  If you keep changing the parameters of what you need eventually people will not help you with your problem.

          Akod

            Topic Starter


            Rookie

            • Certifications: List
            • Experience: Experienced
            • OS: Windows 7
            Re: Batch file to ping everyday and save in notepad
            « Reply #8 on: September 10, 2014, 07:27:29 AM »
            The solution you gave saves the notepad file with the name logfile. I will prefer if it saves it with the name of the current date.

            Squashman



              Specialist
            • Thanked: 134
            • Experience: Experienced
            • OS: Other
            Re: Batch file to ping everyday and save in notepad
            « Reply #9 on: September 10, 2014, 08:08:38 AM »
            This will change the name of the TEXT file with the current date.
            Code: [Select]
            @echo off
            for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set "dt=%%a"
            set "YYYY=%dt:~0,4%"
            set "MM=%dt:~4,2%"
            set "DD=%dt:~6,2%"
            set "HH=%dt:~8,2%"
            set "Min=%dt:~10,2%"
            set "Sec=%dt:~12,2%"
            set "datestamp=%YYYY%%MM%%DD%"
            set "timestamp=%HH%%Min%%Sec%"
            ping IPADDRESS >>"C:\path to log\%datestamp%.txt"

            Akod

              Topic Starter


              Rookie

              • Certifications: List
              • Experience: Experienced
              • OS: Windows 7
              Re: Batch file to ping everyday and save in notepad
              « Reply #10 on: September 10, 2014, 09:06:46 AM »
              Thanks.