How Can I Start Up and Shut Down a Virtual Server Session?

How Can I Start Up and Shut Down a Virtual Server Session?

  • Comments 1
  • Likes
Hey, Scripting Guy! Question

Hey, Scripting Guy! How can I start up and shut down a Virtual Server session?

-- DW

SpacerHey, Scripting Guy! AnswerScript Center

Hey, DW. One of the Scripting Guys once had a neighbor who used to say, over and over again, “You know, I think I should have a garage sale. I really should have a garage sale.” This went on for a couple of years, until the guy finally did have a garage sale. And nobody came. Towards the end of the day someone finally dropped by, and by then the neighbor was so happy to have a customer that he pretty much gave everything away. A few months later he moved (although we don’t know whether that’s because the garage sale was such a disappointment or because he had one of the Scripting Guys as a neighbor).

We can empathize with this ex-neighbor. A year or so ago the Scripting Guys posted a bunch of Virtual Server scripts in the Script Repository, assuming all the while that we’d soon be inundated with questions about scripting Virtual Server. And then nobody came. We know people downloaded the scripts, but nobody ever asked us any questions about scripting Virtual Server. We couldn’t help but feel a little disappointed.

Ah, but then we got your question, and we’re so happy to have a Virtual Server scripting customer that we’re going to pretty much give these scripts away. You want to use a script to start a virtual machine? Well then why didn’t you say so:

Set objVS = CreateObject("VirtualServer.Application")
Set objVM = objVS.FindVirtualMachine("Windows 2000 Server")
objVM.Startup()

Yes, just three lines of code. We begin by creating an instance of the VirtualServer.Application object. We then call the FindVirtualMachine method, passing as a single parameter the name of the machine we want to start (Windows 2000 Server). After that we simply call the Startup() method, and the virtual machine will begin loading. It’s that simple.

It’s equally simple to shut down a virtual machine:

Set objVS = CreateObject("VirtualServer.Application")
Set objVM = objVS.FindVirtualMachine("Windows 2000 Server")
objVM.Turnoff()

Yes, it is identical to the startup script, except for one thing: this time we call the Turnoff() method in order to shut the machine down.

If you find these scripts useful, you might want to take some time and browse through the Virtual Server scripts in the Script Repository. There’s a lot to choose from, and our prices (free) are tough to beat. The Scripting Guys will not be undersold!

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment
  • Thank you Scriting Guy. Im going to check this script. Regards