Page 1 of 1
COM error in PHP
Posted: Thu Aug 31, 2006 5:52 am
by kimi
Hi ALL,
I am trying a PHP script which will automatic startup for virtual machines under Microsoft Virtual Server 2005 r2 but it failed due to COM object saying Source unknown But the same thing when i tried through VB script it works fine.
VB script:
Set objVS = CreateObject("VirtualServer.Application")
Set objVM = objVS.FindVirtualMachine("VM Name")
objVM.Startup();
It Worked fine
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ___________ _ _ _ _ _
PHP Script:
$objVS = new COM(" VirtualServer.Application");
$objVM = $objVS->FindVirtualMachine("Scorpio");
$objVM->Startup();
it throuhgs Error at FindVirtualMachine function saying
ERROR: Fatal error: Uncaught exception 'com_exception' with message 'Source: Unknown
Plese Help me it's urgengt !!
Thanks in advance
Posted: Thu Aug 31, 2006 7:09 am
by volka
Where and how are those both scripts invoked?
What conditions/privileges/... must apply for FindVirtualMachine to find the named machine?
Posted: Thu Aug 31, 2006 8:14 am
by feyd
The COM extension may not be able to find the GUID associated with the string you have giving it. I can see there's a space in the posted code snippet (which should really be in
Code: Select all
tags, by the way). That may confuse COM.
Posted: Thu Aug 31, 2006 8:20 am
by volka
feyd wrote:I can see there's a space in the posted code snippet (which should really be in
Code: Select all
tags, by the way). That may confuse COM.[/quote]Right, but that would raise another exception (message)[quote]Fatal error: Uncaught exception 'com_exception' with message 'Failed to create COM object ` xyz.abc': invalid syntax'[/quote]
edit: at least on winxp it does...
Posted: Tue Sep 05, 2006 1:41 am
by kimi
feyd | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hi,
I tried many times but still it's troughing the same error, i tried some other example but it seems actual problem is in php, it will not accessing COM properly i tried like this
[u]vb script:-[/u]
[syntax="vbnet"]'Script Begins
On Error Resume Next
'Connect to Virtual Server
Set virtualServer = CreateObject("VirtualServer.Application")
'Get collection of virtual machines
set vmCollection = virtualServer.VirtualMachines
'Iterate over the virtual machines and display data
For Each vm in vmCollection
Wscript.Echo "=============================="
Wscript.Echo "Name: " & vm.Name
Wscript.Echo
Wscript.Echo "Notes: " & vm.Notes
Wscript.Echo "=============================="
Next
'Script Ends
Works Fine
PHP Script[/syntax]
Code: Select all
<?php
f1();
function f1()
{
//Connect to Virtual Server
$virtualServer = new COM("VirtualServer.Application");
//Get collection of virtual machines
$vmCollection = $virtualServer->VirtualMachines;
//Iterate over the virtual machines and display data
foreach( $vmCollection as $vm)
{
print("\n==============================");
print( "\nName: " $vm->Name);
print("\n==============================");
}
}
Throughs Run time ERROR:
Code: Select all
Fatal error: Uncaught exception 'com_exception' with message 'Source: Unknown
Description: Unknown' in C:\Program Files\lxlabs\ext\php\test.php:9
Stack trace:
#0 C:\Program Files\lxlabs\ext\php\test.php(9): f1()
#1 C:\Program Files\lxlabs\ext\php\test.php(2): f1()
#2 {main}
thrown in C:\Program Files\lxlabs\ext\php\test.php on line 9
When i cought Exception it will tough Object #2
please help me it's urgent
feyd | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]