ID: 35875 User updated by: csaba at alum dot mit dot edu Reported By: csaba at alum dot mit dot edu Status: Open Bug Type: COM related Operating System: WinXP Pro PHP Version: 5.1.1 New Comment:
I have some additional information on this problem. If I schedule the php task using SchTasks as "Gabor", shown below, then the php script runs fine. In order to be able to do this on my single user, no password system I must first allow Scheduled Tasks to be run without password as described here: http://groups.google.com/group/microsoft.public.windowsxp.general/browse_frm/thread/c1b603be72394ee2/ Then, at the command window I type (on one wrapped line): C:\phpApps>schtasks /Create /SC once /TN schTest /TR "php.exe c:\phpApps\schTest.php" /ST 11:23:00 /RU "Gabor" Just to repeat the original problem: There is a discrepancy when scheduling (as SYSTEM - the default for AT) the php task vs. the vbscript task to do essentially the same thing. The php task errors when its created IE attempts to run code within the task while the vbscript task runs fine. Both scripts run fine when run directly from the command window. Csaba PS. The problem is also exhibited if I ask IE to call into PHP directly (via a PHP class) instead of directing it into a ScriptControl. I illustrated the method shown above because it is the direct analogue of the standard VBScript approach, but I can also provide a "pure" PHP way. However, in that case, when the script is scheduled as SYSTEM (via the AT command) the error is: Permission denied Previous Comments: ------------------------------------------------------------------------ [2006-01-03 03:52:45] csaba at alum dot mit dot edu Description: ------------ My script brings up an instance of IE, and then it places onto IE a function that will execute one of the script's functions (within the script's environment). This is a normal scenario usually achieved through com_event_sink in PHP. However, I have implemented this independent of events. I have both a VB and PHP version, both are working fine from the command line, thanks very much. The problem is that when I run the PHP version using the scheduler (either AT or SchTask), I get an IE error IE right at the point that it tries to call back into the script (a permissions issue?). The scheduled VB version works fine, and if I schedule PHP to invoke the VB version that works just fine, too. Csaba Gabor from Vienna Reproduce code: --------------- <?php $ie = new COM("InternetExplorer.Application"); // new IE $ie->visible = true; $ie->Navigate2("about:blank"); // empty DOM while ($ie->readyState<4) usleep(10000); // wait for IE $window =$ie->document->parentWindow; $window->execScript("window.doneP=false"); // init var $oScript=new COM("MSScriptControl.ScriptControl"); $oScript->Language = "VBScript"; $oScript->AddCode('Sub EvtWrapper() CreateObject("WScript.Shell").Popup _ "ScriptControl reached", 4, "WScript popup", 131120 End Sub'); $oScript->AddObject ("mydoc", $ie->document); $oScript->ExecuteStatement( 'mydoc.onclick=GetRef("EvtWrapper")'); $window->execScript( "window.myfunc=window.document.onclick"); $window->setTimeout("window.myfunc()",100); mypopup("At com_message_pump"); try { while (!$window->doneP) com_message_pump(500); } catch (Exception $e) { popup ("In the catch"); } mypopup ("Done with script"); function mypopup ($text) { $oWSH = new COM("WScript.Shell"); $oWSH->Popup($text, 4, "PHP Popup", 131120); } ?> Expected result: ---------------- I expect this script, schTest.php, to not error when it is scheduled with AT as: AT 14:10 %comspec% "/K php c:\path\to\schTest.php" In particular, just as when it is run directly, IE should come up, and then there should be two popups: "At com_message_pump" followed by "ScriptControl reached". Once IE is dismissed, there should be two more popups: "In the catch" and "Done with script" Actual result: -------------- When SchTest.php is run directly (or via a .vbs invocation) then all four popups show normally. However, when schTest.php is scheduled through AT, then there is an IE error saying Line: 0 Error: Object doesn't support this property or method. When I try the scheduling through SchTask (same results as with AT), then it is scheduled as NT AUTHORITY\SYSTEM (no password). I'm the only user on my system and since I don't have a password, I haven't figured out how to schedule tasks to run under my user name. I am happy to provide the corresponding VBScript code if it would be helpful. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=35875&edit=1
