Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a PHP script. It runs well when I use a browser. It writes an XML file in the same directory. The script takes ~60 seconds to run, and the resulting XML file is ~16 MB.

I am running PHP 5.2.13 via FastCGI on Server 2008 64 bit.

I created a task in task scheduler to run c:\php5\php.exe "D:\inetpub\tools\something.php"

No error returned, but no file created.

If I run this same path and argument at a command line it does not error and does not create the file.

I am doing a simple fopen fwrite fclose to save the contents of a php variable to a .xml file, and the file only gets created when the script is run through the browser.


share|improve this question

Permissions most likely. Try first to use the RUN AS Administrator option to launch the command prompt then see if that creates your file. If so then you know its just permissions.

What user is running the scheduled task? You will need to give that user proper permissions to write to the folder you would like to create the file in.

Do you have UAC turned on?

share|improve this answer
Each time I make a change to the scheduled task properties, a user password box comes up and I enter the administrator account password. When I right click run command prompt as an administrator, the file is still not created. I get my echo statement "file published" that is after the file creation and no error is returned. UAC is on, and I only log into this machine as an Administrator using Remote Desktop. – rg89 May 11 '10 at 15:05
I also tried running the script from D: and C: to see if the drive or folder depth was the cause. I got some warnings earlier this week when I had open_basedir = d:\inetpub earlier this week, so I commented out that line in php.ini. – rg89 May 11 '10 at 15:08
Can you show us your script? Is this server part of a domain? – Campo May 11 '10 at 15:12
Sure, let me figure out the best way to put code into my replies. The server is part of a domain. Windows Server Web edition SP1 64 bit. The code pulls inventory from SQL server, runs a loop to build an XML file for a third party. The task scheduler shows a time lapse of about a minute, which is how long the script takes to run in a browser. – rg89 May 11 '10 at 15:20
I believe the only part of the code that isn't working is the file creation. This is what happens after the loop: $feedContent .= "</feed>"; sqlsrv_close( $conn ); echo "<p>feed built</p>"; $feedFile = "feed.xml"; $handler = fopen($feedFile, 'w'); fwrite( $handler, $feedContent ); fclose( $handler ); echo "<p>file published</p>"; I tried <code> tags. They didn't work. Sorry. – rg89 May 11 '10 at 15:20

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.