Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB Script to auto launch 4 virtual PCs 1

Status
Not open for further replies.

Pyro777

MIS
Jul 14, 2006
47
US
Currently I am running MS Virtual PC 6.0 on Windows Vista. I have 4 virtual PCs that I need automatically start everytime this PC is rebooted (Which is every night, due to company policy) I have been told that it is not possible to auto launch but I am very close with the script that I have wrote. I think that my spacing is off as my script will launch the virtual PC console but not any of my virtul PC sessions. The script below is setup to only launch one virtual PC session for testing purposes. I would also like to place the script into my startup and need for it to wait approx 5 mins before it launches the virtual PC sessions, I am not to sure how to do that Can any one help me ??
Thanks..

Option Explicit

Dim objShell

Set objShell = CreateObject("WScript.Shell")

objShell.Run """C:\program files\Microsoft virtual PC\virtual pc.exe""?singlepc ?pc ws8239v1 ?launch
 
Code:
'wait 5 minutes before proceeding
sTime = Time
Do Until DateDiff("S",sTime,Time) >= 300
	WScript.Echo "wait"
	WScript.Sleep 10
Loop

If you can provide the actual command you can run at a command prompt to launch the virtual PC I can assist you with the rest of the context.

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Thank you very much for the time out portion of the script.

I can launch the virtual pc from the command prompt by going into the folder where the virtual system is located and by typing in WS8239v1.vmc then pressing the enter key. I actually have 2 virtual machines I want to launch but I figured if I had the correct syntax then I would just be able to duplicate it for the second system.

Thanks !!
 
OK, give this a try:

Code:
'wait 5 minutes before proceeding
sTime = Time
Do Until DateDiff("S",sTime,Time) >= 300
    WScript.Echo "wait"
    WScript.Sleep 10
Loop

'Now launch virtual machine
Set WSHShell = CreateObject("Wscript.Shell")
WSHShell.Run Chr(34) & "C:\program files\Microsoft virtual PC\virtual pc.exe" & Chr(34) & " ws8239v1"

If that works then just repeat the last line and change the VM name for your next VM to start.

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Mark,
You totally ROCK !!! I had to do just a bit of tweaking on the code but here is the final product !!!

Option Explicit
Dim WSHShell
'wait 5 minutes before proceeding
sTime = Time
Do Until DateDiff("S",sTime,Time) >= 300
WScript.Echo "wait"
WScript.Sleep 10
Loop

'Now launch virtual machine
Set WSHShell = CreateObject("Wscript.Shell")
WSHShell.Run Chr(34) & "C:\program files\Microsoft virtual PC\virtual pc.exe" & Chr(34) & "-pc WS8239V1 -singlepc -launch"

One last question for you, If I want to launch a second virtual PC right after this one, do i just duplicate the bottom lines and add my other PC ??

Thanks !!!
 
Yes, just duplicate the last line.

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
I tried to duplicate the line with my second Virtual Machine and received an error that KSCV1 virtual system is already running... Any Ideas ?? Here is what I have for my script.

Option Explicit
Dim WSHShell, sTime

'wait 5 minutes before proceeding
sTime = Time
Do Until DateDiff("S",sTime,Time) >= 300
WScript.Sleep 10
Loop

'Now launch virtual machine
Set WSHShell = CreateObject("Wscript.Shell")
WSHShell.Run Chr(34) & "C:\program files\Microsoft virtual PC\virtual pc.exe" & Chr(34) & "-pc KSCV1 -singlepc -launch"

'wait 5 minutes before proceeding
sTime = Time
Do Until DateDiff("S",sTime,Time) >= 120
WScript.Sleep 10
Loop

WSHShell.Run Chr(34) & "C:\program files\Microsoft virtual PC\virtual pc.exe" & Chr(34) & "-pc KSCV2 -singlepc -launch"

 
That code looks OK. While researching the VirtualPC command lines I came across a reference to having some VMs configured for AutoStart. Why don't you configure the 3 or 4 VMs for AutoStart and then just launch the VirtualPC control panel so they will all start up?

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Actually I got it working... The first line launches the Virtual PC console and the KSCV1 Virtual PC, after that all I have to do is go into the folder on the c:\ where the Virtual pcs (.vmc) are located and launch the remaining pcs.. Here is my final code !!!

Option Explicit
Dim WSHShell, WSHShell1, WSHShell2, sTime

'wait 3 minutes before proceeding
sTime = Time
Do Until DateDiff("S",sTime,Time) >= 180
WScript.Sleep 10
Loop

'Now launch virtual machine
Set WSHShell = CreateObject("Wscript.Shell")
WSHShell.Run Chr(34) & "C:\program files\Microsoft virtual PC\virtual pc.exe" & Chr(34) & "-pc KSCV1 -launch"

'wait 1 minute 15 Seconds before proceeding
sTime = Time
Do Until DateDiff("S",sTime,Time) >= 75
WScript.Sleep 10
Loop

Set WSHShell1 = CreateObject("Wscript.Shell")
WSHShell1.Run Chr(34) & "C:\VMPC\KSCV2.vmc"


' 'wait 1 minute 15 Seconds before proceeding
sTime = Time
Do Until DateDiff("S",sTime,Time) >= 75
WScript.Sleep 10
Loop

Set WSHShell2 = CreateObject("Wscript.Shell")
WSHShell2.Run Chr(34) & "C:\VMPC\KSCV3.vmc"

Thank you so much for your help !!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top