...

View Full Version : How to create a batch file for a php script



Rajesh77
06-18-2010, 02:55 PM
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.

Rowsdower!
06-18-2010, 03:32 PM
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/library/cc758944%28WS.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

saviola
06-18-2010, 04:56 PM
You can find useful information here :

Configuring cron jobs on Windows (http://drupal.org/node/31506)
Configuring cron jobs. (http://drupal.org/cron)
Introducing Cron (http://articles.sitepoint.com/article/introducing-cron)

TheBlueblib
06-18-2010, 05:43 PM
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):


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:

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:

CreateObject("Wscript.Shell").Run """" & WScript.Arguments(0) & """", 0, False

and from a launch.bat you can load the entire visible sequence:

inside launch.bat:

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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum