locked
Auto-Start a Windows Virtual PC Guest on Windows 7 RRS feed

  • Question

  • Hello: I'm trying to auto-start a Windows Virtual PC guest on Windows 7.  I am trying to follow the directions found here: http://blogs.technet.com/b/windows_vpc/archive/2009/11/09/auto-start-and-close-options-for-windows-virtual-pc.aspx with little luck.  I'm getting an error that "The configuration value could not be retrieved. The key could not be found." 

    Any suggestions on where the error is? 

     

    My shortcut target is:
    C:\Windows\System32\cscript.exe C:\Scripts\VirtualPCAutoStart.vbs

    The Virtual Machine I'm trying to start is called: VPC

    The VBS Code based on the article linked to:

    Option Explicit   ' Force explicit variable declaration.

    Dim defaultVMTag, defaultVM, objArgs, objVPC, vmName 
    Set objArgs = WScript.Arguments
    Set objVPC = CreateObject("VirtualPC.Application")

    defaultVMTag = "VPC"
    defaultVM = objVPC.GetConfigurationValue(defaultVMTag)

    if objArgs.Count < 1 Then
    WScript.Echo "Syntax: cscript VirtualPCAutoStart.vbs <”VPC”>"
     WScript.Echo "Considering default VM."  
     vmName  = defaultVM
    Else
     vmName  = objArgs(0) 
    End if

    WScript.Echo "Starting VM: """ + vmName + """"
    StartHeadlessVM()

     Sub StartHeadlessVM()
      Dim objVM
      Set objVM = objVPC.FindVirtualMachine(vmName)
      if objVM is Nothing Then
       WScript.Echo "VM not found: """ + vmName + """" 
      Else
      
    Dim objVMTask
       Set objVMTask = objVM.Startup()
       'Set objVMTask = objVM.TurnOff() 'Immediately Turns Off/Powers Down the VM
       'Set objVMTask = objVM.GuestOS.Shutdown(0) 'Controlled Shutdown
       'Set objVMTask = objVM.GuestOS.Shutdown(1) 'Forced Shutdown
       objVMTask.WaitForCompletion -1
       WScript.Echo "VM Started : """ + vmName + ""  
      End if
     End Sub

    Thursday, September 29, 2011 11:20 AM

Answers

  • Hi,

     

    Please check if the virtual PC guest can be started directly.

     

    If you want to auto start Windows Virtual PC via VBScript, please contact Scripting forum to discuss your code.

     

    The Official Scripting Guys Forum!

    http://social.technet.microsoft.com/Forums/en/ITCG/threads/

     

    Best Regards,

    Niki


    Please remember to click "Mark as Answer" on the post that helps you, and to click "Unmark as Answer" if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
    • Marked as answer by Niki Han Monday, October 10, 2011 3:12 AM
    Monday, October 3, 2011 9:29 AM

All replies

  • Hi,

     

    Please check if the virtual PC guest can be started directly.

     

    If you want to auto start Windows Virtual PC via VBScript, please contact Scripting forum to discuss your code.

     

    The Official Scripting Guys Forum!

    http://social.technet.microsoft.com/Forums/en/ITCG/threads/

     

    Best Regards,

    Niki


    Please remember to click "Mark as Answer" on the post that helps you, and to click "Unmark as Answer" if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
    • Marked as answer by Niki Han Monday, October 10, 2011 3:12 AM
    Monday, October 3, 2011 9:29 AM
  • Comment out: defaultVM = objVPC.GetConfigurationValue(defaultVMTag)

    Make sure you pass a vmname to the script and it'll work. I had the same issue, found your thread, solved the issue, felt a solution should be posted even if its in the wrong forum. Sorry for not following the rules but thats how things get done in the real world :)

    • Proposed as answer by Scott CT Thursday, March 8, 2012 5:05 PM
    Thursday, March 8, 2012 5:05 PM