vboxinfo.vbs revision d8a22c2ad3ccd177ad5cf49d3276cdf3edcb0ec5
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk'
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk' Copyright (C) 2009 Sun Microsystems, Inc.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk'
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk' This file is part of VirtualBox Open Source Edition (OSE), as
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk' available from http://www.virtualbox.org. This file is free software;
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk' you can redistribute it and/or modify it under the terms of the GNU
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk' General Public License (GPL) as published by the Free Software
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk' Foundation, in version 2 as it comes in the "COPYING" file of the
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk' VirtualBox OSE distribution. VirtualBox OSE is distributed in the
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk' hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk'
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk' Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk' Clara, CA 95054 USA or visit http://www.sun.com if you need
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk' additional information or have any questions.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk'
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenkSub Print(str)
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk Wscript.Echo str
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenkEnd Sub
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenkSub StartVm(vb, mach)
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk Dim session, progress
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk Set session = CreateObject("VirtualBox.Session")
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk Set progress = vb.openRemoteSession(session, mach.id, "gui", "")
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk progress.waitForCompletion(-1)
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk session.close()
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenkEnd Sub
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenkSub StopVm(vb, mach)
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk Dim session, progress
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk Set session = CreateObject("VirtualBox.Session")
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk vb.openExistingSession session, mach.id
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk session.console.powerDown().waitForCompletion(-1)
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk session.close()
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenkEnd Sub
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenkSub Main
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk Dim vb, mach
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk set vb = CreateObject("VirtualBox.VirtualBox")
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk Print "VirtualBox version " & vb.version
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk ' Safe arrays not fully functional from Visual Basic Script, as we
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk ' return real safe arrays, not ones wrapped to VARIANT and VBS engine
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk ' gets confused. Until then, explicitly find VM by name.
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk ' May wish to use hack like one described in
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk ' http://www.tech-archive.net/Archive/Excel/microsoft.public.excel.programming/2006-05/msg02796.html to handle safearrays
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk ' if desperate
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk Set mach = vb.findMachine("Win")
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk Print "Machine: " & mach.name & " ID: " & mach.id
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk StartVm vb, mach
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenkEnd Sub
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenkMain
5b64d5d44892834ba97f003080f3467299b7c5c5jeff.schenk