Select Page

I found this useful bit of VBScript code from Ben Armstrong:

Here it is basically:
Option Explicit

Dim VMList
Dim VMName

‘Specify the name of the virtual machine that I want to start
VMName = “Windows Server 2003”

‘Get instance of ‘virtualization’ WMI service on the local computer
Set WMIService = GetObject(“winmgmts:\.rootvirtualization”)

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

‘ Request a state change on the first VM that is returned
‘ 2 = start, 3 = stop and 32769 = save state

Pin It on Pinterest

Share This