Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Jun 2010
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to create a batch file for a php script

    Hi everyone ,

    I need to schedule a php script to run daily at night 11:59 pm .
    So i need to create a batch file for php script to schedule with the windows scheduler .
    I am not getting how create a batch file for a php script .

    Please tell me the code to create the batch file for php script . suppose my script name is post_mail.php .
    Please help me out this issue .. Thank u in advance .

    Thank,
    Rajesh.

  • #2
    Senior Coder Rowsdower!'s Avatar
    Join Date
    Oct 2008
    Location
    Some say it's everything.
    Posts
    2,027
    Thanks
    5
    Thanked 397 Times in 390 Posts
    Quote Originally Posted by Rajesh77 View Post
    Hi everyone ,

    I need to schedule a php script to run daily at night 11:59 pm .
    So i need to create a batch file for php script to schedule with the windows scheduler .
    I am not getting how create a batch file for a php script .

    Please tell me the code to create the batch file for php script . suppose my script name is post_mail.php .
    Please help me out this issue .. Thank u in advance .

    Thank,
    Rajesh.
    It's a Windows server (which I don't have direct experience with) but I believe you just create a batch (*.bat) file as you would for a regular Windows PC.

    There are some details here if you want to build it manually:
    http://technet.microsoft.com/en-us/l...8WS.10%29.aspx

    And an example for some CMS program, but the basic steps should be the same:
    http://www.sugarcrm.com/forums/showthread.php?t=7952
    The object of opening the mind, as of opening the mouth, is to shut it again on something solid. G.K. Chesterton
    See Mediocrity in its Infancy
    It's usually a good idea to start out with this at the VERY TOP of your CSS: * {border:0;margin:0;padding:0;}
    Seek and you shall find... basically:
    validate your markup | view your page cross-browser/cross-platform | free web tutorials | free hosting

  • #3
    New Coder
    Join Date
    Jun 2010
    Posts
    20
    Thanks
    0
    Thanked 1 Time in 1 Post
    Nothing's imposible imagination is everything!
    Database Benchmark Software (GNU GPL) | world's fastest database

  • #4
    New Coder
    Join Date
    May 2009
    Posts
    75
    Thanks
    1
    Thanked 12 Times in 12 Posts
    Assuming you have internet explorer running, you can call a vbs script from a batch file to open the php page through IE. For example:

    This is inside foo.vbs (notice the location of your script):

    Code:
    Dim objIEA
    Set objIEA = CreateObject("InternetExplorer.Application")
    objIEA.Navigate "http://localhost/post_mail.php"
    While objIEA.Busy
    Wend
    Set objIEA = Nothing
    then call foo.vbs from a batch file.

    this is inside bar.bat:
    Code:
    wscript.exe "C:\foo.vbs"
    The internet explorer window should be invisible. If you want the batch file to be invisible too, you can mask it with this invis.vbs script:

    inside invis.vbs:
    Code:
    CreateObject("Wscript.Shell").Run """" & WScript.Arguments(0) & """", 0, False
    and from a launch.bat you can load the entire visible sequence:

    inside launch.bat:
    Code:
    wscript.exe "C:\invis.vbs" "C:\bar.bat"
    Now all you need to do is go to scheduled tasks and schedule launch.bat to run at whatever interval you want. Make sure all the file locations are correct.

    EDIT: Test out loading your script from a normal internet explorer window first. Make sure all security settings in IE allow you to load the script. When I tried it, a plug in interfered and I had to disable it before it worked.
    Last edited by TheBlueblib; 06-18-2010 at 05:48 PM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •