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

Author Topic: Batch file problems windows XP  (Read 6356 times)

0 Members and 1 Guest are viewing this topic.

tomlevett

    Topic Starter


    Newbie

    • Experience: Beginner
    • OS: Windows 7
    Batch file problems windows XP
    « on: December 23, 2015, 01:55:38 PM »
    Hi All,
    New to this but I'm trying to set up a .bat or .cmd file to run a ping every 12 hours on a loop and record it in a file.

    I've got the below running (set to every 6 seconds for trialing) successfully in windows 7 but it won't work in XP.

    @ECHO on
    set IPADDRESS=8.8.8.8
    set INTERVAL=6
    :PINGINTERVAL
    ping %IPADDRESS% -n 1 >> C:\test.txt
    time /T >> C:\test.txt
    date /T >> C:\test.txt
    timeout %INTERVAL%
    GOTO PINGINTERVAL



    I also tried this one
    @ECHO on
    cls
    :start
    ping 8.8.8.8 -n 1 >> d:\test.txt
    echo logged time = %time% %date% >> d:\test.txt
    timeout /t 6
    goto start


    both work fine in windows 7, but not XP.

    Thanks in advance

    Geek-9pm


      Mastermind
    • Geek After Dark
    • Thanked: 1026
      • Gekk9pm bnlog
    • Certifications: List
    • Computer: Specs
    • Experience: Expert
    • OS: Windows 10
    Re: Batch file problems windows XP
    « Reply #1 on: December 23, 2015, 03:20:38 PM »
    You can make it work. Some observations.
    Until you get thing thing working, do not use a loo forever thing. Maybe just loop five times to see what is in the report file.

    Also, the report file should be cleared the first time you use it.
    Instead of a timer. maybe your should schedule the job to be done through the days.

    What is this?
    Code: [Select]
    timeout %INTERVAL%Timeout is not found in my XP.
    It is part of Windows 7/2008 and XP Resource Kit
    https://technet.microsoft.com/en-us/library/cc754891.aspx
    Also see:
    Running Scheduled Task Multiple Times a Day

    DaveLembke



      Sage
    • Thanked: 662
    • Certifications: List
    • Computer: Specs
    • Experience: Expert
    • OS: Windows 10
    Re: Batch file problems windows XP
    « Reply #2 on: December 23, 2015, 03:44:44 PM »
    Did you install the Timeout from the resource kit and is Timeout.exe located in same location as the batch file to run?

    I usually use the sleep command instead myself, but you will need to make sure you have sleep.exe if your going to use that instead.

    More info here on Sleep vs Timeout http://stackoverflow.com/questions/28057443/difference-between-sleep-and-timeout

    Geek-9pm


      Mastermind
    • Geek After Dark
    • Thanked: 1026
      • Gekk9pm bnlog
    • Certifications: List
    • Computer: Specs
    • Experience: Expert
    • OS: Windows 10
    Re: Batch file problems windows XP
    « Reply #3 on: December 23, 2015, 03:53:45 PM »
    DaveLembke, good catch.  :)

    DaveLembke



      Sage
    • Thanked: 662
    • Certifications: List
    • Computer: Specs
    • Experience: Expert
    • OS: Windows 10
    Re: Batch file problems windows XP
    « Reply #4 on: December 23, 2015, 04:30:51 PM »
    Well you knew like me that its not a normal part of XP and part of resource kit to be added for Timeout support. If that isnt installed and/or Timeout.exe not located in the directory that the batch is executed it will just return with invalid command. Hopefully this fixes it for them. If the resource kit is installed it should auto resolve for the Timeout instruction, however if they didnt install the resource kit but placed the Timeout.exe file in the same directory with the batch instruction it would probably work the same as the trick to add the Sleep command to systems that didnt come with it.  :)

    Geek-9pm


      Mastermind
    • Geek After Dark
    • Thanked: 1026
      • Gekk9pm bnlog
    • Certifications: List
    • Computer: Specs
    • Experience: Expert
    • OS: Windows 10
    Re: Batch file problems windows XP
    « Reply #5 on: December 23, 2015, 04:49:58 PM »
    Also, ping can be used for a time delay, if you are using ping anyway. Still, I thunk for doing the whole day should be in Task Schedule.


    BC_Programmer


      Mastermind
    • Typing is no substitute for thinking.
    • Thanked: 1140
      • Yes
      • Yes
      • BC-Programming.com
    • Certifications: List
    • Computer: Specs
    • Experience: Beginner
    • OS: Windows 11
    Re: Batch file problems windows XP
    « Reply #6 on: December 24, 2015, 01:08:09 AM »
    Also, ping can be used for a time delay, if you are using ping anyway. Still, I thunk for doing the whole day should be in Task Schedule.

    I'd say for any delay more than 5 minutes or so is better approached with Task Scheduler, myself.
    I was trying to dereference Null Pointers before it was cool.