I'm having the oddest problem ever with Windows 7: My scripts positively CAN create files in a given directory, but then are unable to delete those same files.

My server is currently a local XAMPP, and I don't have this issue in ubuntu, centOS or a windows XP VM I have. Only on the Windows 7 one.

The files permissions are such that Everyone has full control, SYSTEM has full control, and my own user also has full control.

The directory is C:\Users\cfv\Desktop\kit and I'm running the scripts in the following manner:

Windows+R -> cmd -> php script.php

What exactly am I doing wrong here and how do I set the environment up in a manner that allows me to delete this files I'm creating?

link|improve this question
we're going to need a bit more info then that. Post the script code, post any errors that you encounter. – Eric C. Singer Jan 21 at 21:28
I don't really see how the source would have anything to do, but help yourself to it. Source of the script that creates the files: bitbucket.org/cfv1984/kihon/src/c8b6d379314c/lib/Console/Task/… Source of the script that deletes the files: bitbucket.org/cfv1984/kihon/src/d01c86c7290d/lib/Console/Task/… – Carlos Vergara Jan 21 at 21:58
It should be noted that this throws absolutely NO errors on any machine, it simply does not delete anything it created previously. – Carlos Vergara Jan 21 at 22:00
feedback

2 Answers

while it shouldn't be required within your local profile, one thing to try, would be...

do a search for "cmd", right click CMD and select "run as administrator". Then run your same command.

Also, just a guess, but make sure you change to the directory where you want it to clean up the files. Maybe it searching where ever your CMD window starts and not the dirrectory you actually want it to clean.

Also, is there a reason that it needs to be a PHP script?

link|improve this answer
The main reason would be that I'm building an application framework from scratch in PHP. Those two scripts I've shown there work consistently right in everything but Windows 7, which is what's driving me nuts. Maybe php from command line runs as a different user than from apache? – Carlos Vergara Jan 21 at 22:10
I mean, I made this BAT file with the following line: DEL /s *.bak And it sure enough deletes the files without complaining. It has to be something with the PHP binary and its permissions to do stuff – Carlos Vergara Jan 21 at 22:14
Nope, no luck. Running as an administrator or otherwise, it's failing to delete but being able to write. – Carlos Vergara Jan 21 at 22:15
ok, so are you trying to delete the files with apache or as your self? If you're actually opening the command line and running the script, then that would be running as you. If the script isn't running correctly as you, and the permissions are set as you've stated and you've tried running as administrator, then i would point back to something with PHP and not with your permissions. – Eric C. Singer Jan 21 at 22:19
oh and since you're saying it works with a CMD file, my money is that it must lie within the PHP bit. – Eric C. Singer Jan 21 at 22:20
feedback

I have the same problem when fclose and unlink are in the callback method which called by register_shutdown. After separation of fclose to another method which called before register_shutdown the problem has gone away.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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