Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > Virtual Server

Vista - Hyper-V Startup Script Not Working

Reply
 
Old 08-27-2009   #1 (permalink)
Joe


 
 

Hyper-V Startup Script Not Working

I am trying to use the following vbscript to start a Win2K3 guest on a
Hyper-V server running on Win2k8. The shutdown script runs fine, but when I
run this script to startup the same VM, I get the error:

Microsoft VBScript runtime error: Object doesn't support this property or
method: 'ItemIndex'

I got this code from the Virtual PC guy's blog, and I've seen reference to
it in many places. Can you tell me why this is not working? I am running
the script from my backup server, which is Win2K3.

Thanks,
Joe

Code Snippet:
Dim VMList
Dim VMName
Dim VMGuid
Dim ShutdownList
Dim Result

'Specify the name of the virtual machine that I want to shutdown
VMName = "PrinterVM"

'Get instance of 'virtualization' WMI service on the local computer
Set WMIService = GetObject("winmgmts:\\printserver\root\virtualization")

'Query for the specific virtual machine that I want to shutdown
Set VMList = WMIService.ExecQuery("SELECT * FROM Msvm_ComputerSystem WHERE
ElementName='" & VMName & "'")

'Get the GUID for the virtual machine I want to shutdown
'VMGuid = VMList.ItemIndex(0).Name

'Query for the MSVM_ShutdownComponent that corresponds to the VM GUID that I
have
'Set ShutdownList = WMIService.ExecQuery("SELECT * FROM
Msvm_ShutdownComponent WHERE SystemName='" & VMGuid & "'")

' Request a state change on the first VM that is returned
' 2 = start, 3 = stop and 32769 = save state
VMList.ItemIndex(0).RequestStateChange(2)

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Startup-script to change hostname and IP if not OK VB Script
Startup Script Via GPO... Where Are Parameters Stored? VB Script
Script works / but fails on startup VB Script
Shutdown and startup Hyper-V Virtual Machine via script Virtual Server
Trivial startup script won't run in Vista Vista account administration


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46