i need a batch code

Discussion in 'Programming' started by Sir Najeeb, Jan 12, 2012.

  1. #1
    hi guys
    i need a batch code that runs a file automatically in a specific time
    example :
    i have a file named as test.bat and i want to insert a code in it to make it runs at 1:00 am
    please help me
     
    Sir Najeeb, Jan 12, 2012 IP
  2. codecre8r

    codecre8r Well-Known Member

    Messages:
    148
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    128
  3. sarahk

    sarahk iTamer Staff

    Messages:
    28,830
    Likes Received:
    4,541
    Best Answers:
    123
    Trophy Points:
    665
    #3
    Sounds like a fairly straight forward cron job - have you tried that?
     
    sarahk, Jan 13, 2012 IP
  4. instant-automation

    instant-automation Member

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    38
    Digital Goods:
    1
    #4
    A cron job is a macro for a server... if your dealing with a batch file your referring to a user's local machine.


    The bottom line, they both do the same thing ... automate tasks on a schedule. But each has different coding.
     
    instant-automation, Jan 13, 2012 IP
  5. sarahk

    sarahk iTamer Staff

    Messages:
    28,830
    Likes Received:
    4,541
    Best Answers:
    123
    Trophy Points:
    665
    #5
    I guess that is something we need "Sir" Najeeb to clarify. Is he doing it on his website or his own computer - if so is it a PC, Mac or Linux - hell, he could be trying to do it on an android tablet or his iphone?!! Then again he does say test.bat so it must be a PC, right?
     
    sarahk, Jan 13, 2012 IP
  6. instant-automation

    instant-automation Member

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    38
    Digital Goods:
    1
    #6
    A batch file can be executed in Windows, or Mac. Basically any DOS based system.

    A Cron job is for UNIX based systems. Most server use Linux and thus most cron jobs are referring to a server script.

    Again, same basic idea, just different terms.

    Also, to run any cron on an iphone, it must be jail broken.
     
    Last edited: Jan 13, 2012
    instant-automation, Jan 13, 2012 IP
  7. <?php

    <?php Greenhorn

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #7
    Hi,

    Use the AT command for DOS, for Windows Vista and 7 use schtasks.exe

    for AT.exe use this command.

    Let's say you want to create a folder in the temp dir in C drive. Here's a batch file that creates a folder with the current date of the time it was created.

    folder.bat [path: C:\folder.bat]
    -------------
    @echo off
    cd c:\temp
    set folder=%date:~10,4%%date:~7,2%%date:~4,2%
    mkdir %folder%
    move c:\temp c:\%folder%
    ---------------------------

    Then open cmd [Run as Administrator]
    execute this command so it will run only once at, for example, 8:30:00 PM
    >at.exe 20:30 /interactive C:\folder.bat

    And it will give you message:
    "Added a new job at job ID = 1"
    Then you can check the time and status with the command
    >at 1


    For schtasks.exe use the following command: [with date: Jan 13 2012 and time 8:30 PM]

    >schtasks /create /tn "My Batch File" /tr C:\folder.bat /sc once /st 20:30:00 /sd 01/13/2012
    Hit enter
    "SUCCESS: The scheduled task "My Batch File" has successfully been created.


    Then go to C:\temp folder and you should see a new created folder with the name of the current date [the date it batch file was executed].

    Also, check out these sites for the command lists
    AT commmands : computerhope.com/at.htm
    schtasks: technet.microsoft.com/en-us/library/bb490996.aspx
     
    <?php, Jan 13, 2012 IP