![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | 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 Specs![]() |
![]() |
| 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 | |||