最近对操作系统挺有兴趣的,实验了一下!准备找一个虚拟机,之前在xp上使用virtual pc感觉不错,准备在本机上装一下,但是发现居然不支持软盘了!

查阅了各种资料,终于找到了解决的办法。

1. 下载脚本 Scripts.zip 在如下地址:http://blogs.msdn.com/b/virtual_pc_guy/archive/2009/10/01/using-floppy-disks-with-windows-virtual-pc.aspx

  也可以自己生成两个脚本文件,代码如下

  FloppyDrive.vbs  

Option Explicit

' Define constants for floppy drive attachment types
CONST vmFloppyDrive_None =
CONST vmFloppyDrive_Image =
CONST vmFloppyDrive_HostDrive = Dim namedArguments, argumentError, vpc, vm, vmName, action, floppy, vmFloppyDrive ' Check that the script is running at the command line.
If UCase(Right(Wscript.FullName, )) = "WSCRIPT.EXE" Then
WScript.Echo "This script must be run under CScript."
WScript.Quit
End If ' Get the virtual machine name / floppy commands from the command-line arguments
Set namedArguments = WScript.Arguments.Named argumentError = false If namedArguments.Exists("vm") Then
vmName = namedArguments.Item("vm")
Else
argumentError = true
End If If namedArguments.Exists("action") Then
action = namedArguments.Item("action")
Else
argumentError = true
End If If namedArguments.Exists("floppy") Then
floppy = namedArguments.Item("floppy")
Else
If (not ((action = "info") or (action = "disconnect"))) Then
argumentError = true
End If
End If ' Display usage information if wrong arguments are provided
if argumentError then
WScript.Echo "Missing command-line argument"
WScript.Echo
WScript.Echo "Usage: FloppyDrive.vbs /vm:" & chr() & "Name of virtual machine to be started" & chr()
WScript.Echo
WScript.Echo " /action:info - to display information about the current floppy configuration"
WScript.Echo " disconnect - to disconnect any attached floppy disk or floppy disk image"
WScript.Echo " vfd - to attach a virtual floppy disk image"
WScript.Echo " physical - to attach a physical floppy disk"
WScript.Echo
WScript.Echo " /floppy:name - where name is either the full name and path for a virtual"
WScript.Echo " floppy disk or the letter of a physical disk to attach"
WScript.Echo
WScript.Quit
end if ' Attempt to connect to Virtual PC
On Error Resume Next
Set vpc = CreateObject("VirtualPC.Application")
If Err.Number <> Then
WScript.Echo "Unable to connect to Virtual PC."
WScript.Quit
End if
On Error Goto ' Get virtual machine object
Set vm = vpc.FindVirtualMachine(vmName) ' Get the floppy drive
set vmFloppyDrive = vm.FloppyDrives.item() ' Perform the specified action
Select Case action ' Display floppy disk information
case "info"
wscript.echo "Floppy disk information"
wscript.echo "=======================" ' Different information is needed for each attachment type
select case vmFloppyDrive.Attachment
case vmFloppyDrive_None
wscript.echo "Floppy Attachment : No floppy disk attached"
wscript.echo "Drive Number : " & vmFloppyDrive.DriveNumber
case vmFloppyDrive_Image
wscript.echo "Floppy Attachment : Floppy disk image attached"
wscript.echo "Drive Number : " & vmFloppyDrive.DriveNumber
wscript.echo "Image File : " & vmFloppyDrive.ImageFile
case vmFloppyDrive_HostDrive
wscript.echo "Floppy Attachment : Physical floppy disk attached"
wscript.echo "Drive Number : " & vmFloppyDrive.DriveNumber
wscript.echo "Host Drive Letter : " & vmFloppyDrive.HostDriveLetter
end select ' Disconnect the current floppy disk
case "disconnect" wscript.echo "Disconnecting the floppy disk." ' A different method is used to disconnect a floppy disk image than for a physical disk
select case vmFloppyDrive.Attachment
case vmFloppyDrive_Image
vmFloppyDrive.ReleaseImage
case vmFloppyDrive_HostDrive
vmFloppyDrive.ReleaseHostDrive
end select ' Attach a floppy disk image
case "vfd" wscript.echo "Attaching " & floppy & " to the floppy drive."
vmFloppyDrive.AttachImage(floppy) ' Attach a physical floppy disk
case "physical" wscript.echo "Attaching physical disk " & floppy & ": to the floppy drive."
vmFloppyDrive.AttachHostDrive(floppy) ' Catch invalid actions
case else
wscript.echo "Invalid action provided. Info, disconnect, vfd and physical are valid options." end select wscript.echo

  FloppyDrive.ps1

param([string]$vmName, [string]$action, [string]$floppy)

$argumentError =

# Check for correct command-line arguments
If ($vmName -eq "")
{$argumentError = } If ($action -eq "")
{$argumentError = } If ($floppy -eq "")
{
if ((!([string]::Compare($action, "vfd", $True))) -or (!([string]::Compare($action, "physical", $True))))
{$argumentError = }
} # Display usage information if wrong arguments are provided
If ($argumentError -eq )
{
write-host "Missing command-line argument."
write-host "USage: FloppyDrive.ps1 -vmName `"Name of virtual machine`""
write-host " -action info - to display information about the current floppy configuration"
write-host " disconnect - to disconnect any attached floppy disk or floppy disk image"
write-host " vfd - to attach a virtual floppy disk image"
write-host " physical - to attach a physical floppy disk"
write-host
write-host " -floppy name - where name is either the full name and path for a virtual"
write-host " floppy disk or the letter of a physical disk to attach"
exit
} # Connect to Virtual PC
$vpc=new-object 朿om VirtualPC.Application 朣trict # Get virtual machine object
$vm = $vpc.FindVirtualMachine($vmName) # Get the floppy drive
$vmFloppyDrive = $vm.FloppyDrives.item() # Perform the specified action
switch ($action)
{ # Display floppy disk information
"info" {
write-host "Floppy disk information"
write-host "=======================" # Different information is needed for each attachment type
switch ($vmFloppyDrive.Attachment)
{
{
write-host "Floppy Attachment : No floppy disk attached"
write-host "Drive Number : " $vmFloppyDrive.DriveNumber}
{
write-host "Floppy Attachment : Floppy disk image attached"
write-host "Drive Number : " $vmFloppyDrive.DriveNumber
write-host "Image File : " $vmFloppyDrive.ImageFile }
{
write-host "Floppy Attachment : Physical floppy disk attached"
write-host "Drive Number : " $vmFloppyDrive.DriveNumber
write-host "Host Drive Letter : " $vmFloppyDrive.HostDriveLetter }
}
} # Disconnect the current floppy disk
"disconnect" { write-host "Disconnecting the floppy disk." # A different method is used to disconnect a floppy disk image than for a physical disk
switch ($vmFloppyDrive.Attachment)
{
{$vmFloppyDrive.ReleaseImage()}
{$vmFloppyDrive.ReleaseHostDrive()}
}
} # Attach a floppy disk image
"vfd" {
write-host "Attaching " $floppy " to the floppy drive."
$vmFloppyDrive.AttachImage($floppy)
} # Attach a physical floppy disk
"physical" {
write-host "Attaching physical disk " $floppy ": to the floppy drive."
$vmFloppyDrive.AttachHostDrive($floppy)
} # Catch invalid actions
default {write-host "Invalid action provided. Info, disconnect, vfd and physical are valid options."}
}

2. 将两个脚本文件放置在同一个目录下

3. 打开命令行,进入存放脚本文件的目录

4. 运行如下的命令:

  cscript FloppyDrive.vbs /vm:"myTestOS" /action:vfd /floppy:"C:\E\work\VirtualPC\helloos.vfd"

  红色字体部分分别是虚拟机的名字,虚拟软盘的文件(必须是vfd后缀,可以吧img文件改为vfd文件)

04-29 22:59