Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.
'USB devices to a Virtual Machine. 'Usage: cscript ScriptName <vmname> <Device String> 'Validate the Parameters If WScript.Arguments.Count <> 2 Then Wscript.Echo "Usage: cscript ScriptName <vmname> <Device Name>" WScript.Quit 1 End If 'Get the Virtual PC Object Set objVPC = CreateObject("VirtualPC.Application") 'Find the Virtual Machine Set objVM = objVPC.FindVirtualMachine(WScript.Arguments(0)) If objVM is Nothing Then Wscript.Echo "Unable to Find the Virtual Machine: " & WScript.Arguments(0) WScript.Quit 2 End If 'Get the USB devices collection set usbDevicesColl = objVPC.USBDeviceCollection If usbDevicesColl.Count = 0 Then Wscript.Echo "There are no USB Devices Connected to the machine." WScript.Quit 2 End If 'Display the Currently Connected USB Devices 'Wscript.Echo "USB Devices Connected to the machine" For Each usbDevice in usbDevicesColl 'Wscript.Echo "USB Device Name: " & usbDevice.DeviceString Next on error resume next 'Variable to find if Device is Found isFound = 0 For Each usbDevice in usbDevicesColl if LCase(usbDevice.DeviceString) = LCase(WScript.Arguments(1)) Then 'Attach the USB device to VM set objAssign = objVM.AttachUSBDevice(usbDevice) isFound = 1 break End If Next If isFound = 0 Then Wscript.Echo "Unable to find the USB device. Please check the device string." Else 'Wscript.Echo "The Device is assigned to the Virtual Machine." End If
Feel free to customize the code, I actually borrowed this and tweaked it a little from another forum; unfortunately I can not find that forum again so... cant post a link to it to provide that user with credit, however... for the record, it is not my source code, I have just modified it by commenting out some MSG boxes to provide a more seamless attachment of the usb devices.
To make this code work, you are running the script with two parameters, 1: The name of the Virtual Machine, 2: The name of the USB device to attach as it shows within the VM session. Both of these parameters should be passed as delimited strings. Example: "Windows XP Mode" "Cardjet Printer"
Example of the entire command: C:\path\script.vbs "Windows XP Mode" "Cardjet Printer"
I would recommend setting this up in a similar way that I do right now. I have the script located on a completely open share for the enterprise, and then have a created task on the machine hosting the VM. This task is set to run whenever event 213 from Virtual PC is triggered, it then runs the script with the specified arguments/parameters. I have a separate action created for each usb device that needs to be attached. Remember that these device names are the exact names specified within the session, so... if you havent installed the drivers yet, dont setup the script until after that has been done, since the proper name of the device will only show once the drivers have been installed (until then, it should be listed as unspecified, or unknown device, which is useless).
Until Microsoft incorporates this as a standard integrated feature, this I believe is the best method for attaching USB devices to Windows XP Mode sessions.
Thanks, and I hope this helps.