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
COM error in PHP
Moderator: General Moderators
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
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.feyd wrote:I can see there's a space in the posted code snippet (which should really be inCode: 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...
feyd | Please use
Works Fine
PHP Script[/syntax]
Throughs Run time ERROR:
When i cought Exception it will tough Object #2
please help me it's urgent
feyd | Please use
Code: Select all
,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 EndsPHP 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==============================");
}
}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 9When i cought Exception it will tough Object #2
please help me it's urgent
feyd | Please use
Code: Select all
,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]