OtagoHarbour Posted May 28, 2011 Share Posted May 28, 2011 I use the following code to delete a subdirectory in the user's directory on a Windows system. $setDir= "f:\\ServerDirectory\\" . $_SESSION['UserName'] . "\\" . $setName; $str="del/q " . $setDir; echo "Delete string: " . $str . "<br \>"; $Result=exec($str, $output, $return); echo "Delete status:" . $output . " " . $return . "<br \>";The screen output is as follows.Delete string: del/q f:\ServerDirectory\UserDir\SubDirDelete status:Array 0Unfortunately, the subdirectory is not deleted.I would be grateful if someone could tell me what I am doing wrong.Thanks,Peter. Link to comment Share on other sites More sharing options...
justsomeguy Posted May 28, 2011 Share Posted May 28, 2011 The output array may contain an error message.echo "Delete status:" . implode('<br />', $output) . " " . $return . "<br \>"; Link to comment Share on other sites More sharing options...
OtagoHarbour Posted May 28, 2011 Author Share Posted May 28, 2011 The output array may contain an error message.echo "Delete status:" . implode('<br />', $output) . " " . $return . "<br \>";I have just tried that but unfortunately all I got wasDelete status: 0Thanks,Peter. Link to comment Share on other sites More sharing options...
justsomeguy Posted May 28, 2011 Share Posted May 28, 2011 What if you do this:print_r($output);It sounds like there is no output from the command.Does the command work if you run it in a command prompt manually? Link to comment Share on other sites More sharing options...
OtagoHarbour Posted May 28, 2011 Author Share Posted May 28, 2011 What if you do this:print_r($output);It sounds like there is no output from the command.Does the command work if you run it in a command prompt manually?Sorry. It was my mistake. I was supposed to be usingrmdir/s/qinstead ofdel/qThe output from print_r($output);wasArray ( ) Thank you for your help,Peter. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.