Share via


Using Floppy Disks with Windows Virtual PC

Most users of Windows Virtual PC do not need to use floppy disks with their virtual machines, as general usage of floppy disks has become rarer and rarer.  Those who do need to use floppy disks – may think that they can no longer do this – as there is no user interface for connecting floppy disks to virtual machines.

Do not be fooled.

Windows Virtual PC does support the use of floppy disks – but as this feature is only used by a small subset of users – we did not expose this in the user interface.  To use floppy disks you need to have a script to help you.  And here are the scripts:

VBScript:

 Option Explicit
  
 ' Define constants for floppy drive attachment types
 CONST vmFloppyDrive_None = 0
 CONST vmFloppyDrive_Image = 1
 CONST vmFloppyDrive_HostDrive = 2
  
 Dim namedArguments, argumentError, vpc, vm, vmName, action, floppy, vmFloppyDrive
  
 ' Check that the script is running at the command line.
 If UCase(Right(Wscript.FullName, 11)) = "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(34) & "Name of virtual machine to be started" & chr(34)
  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 <> 0 Then
  WScript.Echo "Unable to connect to Virtual PC."
  WScript.Quit
 End if
 On Error Goto 0
  
 ' Get virtual machine object
 Set vm = vpc.FindVirtualMachine(vmName)
  
 ' Get the floppy drive
 set vmFloppyDrive = vm.FloppyDrives.item(1)
  
 ' 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

PowerShell:

 param([string]$vmName, [string]$action, [string]$floppy)
  
 $argumentError = 0
  
 # Check for correct command-line arguments
 If ($vmName -eq "")
  {$argumentError = 1}
  
 If ($action -eq "")
  {$argumentError = 1}
  
 If ($floppy -eq "")
  {
   if ((!([string]::Compare($action, "vfd", $True))) -or (!([string]::Compare($action, "physical", $True))))
   {$argumentError = 1}
  }
  
 # Display usage information if wrong arguments are provided
 If ($argumentError -eq 1)
  {
  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 –com VirtualPC.Application –Strict
  
 # Get virtual machine object
 $vm = $vpc.FindVirtualMachine($vmName)
  
 # Get the floppy drive
 $vmFloppyDrive = $vm.FloppyDrives.item(1)
  
 # 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)
         {
         0 {
            write-host "Floppy Attachment : No floppy disk attached"
            write-host "Drive Number      : " $vmFloppyDrive.DriveNumber}
         1 { 
            write-host "Floppy Attachment : Floppy disk image attached"
            write-host "Drive Number      : " $vmFloppyDrive.DriveNumber
            write-host "Image File        : " $vmFloppyDrive.ImageFile }
         2 { 
            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)
          {
          1 {$vmFloppyDrive.ReleaseImage()}
          2 {$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."}
    }

These scripts are fairly “self documenting” and will provide error messages if the wrong input is provided.  They will allow you to connect both physical and virtual floppy disks to a virtual machine.  As well as to check the information about the current floppy disk configuration.

I have also attached these scripts for download.

Cheers,
Ben

Floppy Drive Scripts.zip

Comments

  • Anonymous
    October 01, 2009
    ex-VPC user - I am sorry, but I had to delete your comment due to your use of profanity.  But to answer your questions: The UI for floppies was not deleted.  It was never created.  The entire Windows Virtual PC UI is a new creation - and floppy settings were not included in it. If you need to run this as part of a batch file you can do that by just running the command: cscript.exe FloppyDrive.vbs Cheers, Ben

  • Anonymous
    October 02, 2009
    The comment has been removed

  • Anonymous
    October 03, 2009
    You did have a UI for floppy support. As you say, you had a whole interface you threw away. for what? To dumb it down and make it less useful. You also ised to have a great product for the Mac, but no more. Interest is waning and I have to agree with Jason.

  • Anonymous
    October 03, 2009
    Thanks Ben, I will looking at the code and will look to building a GUI to allow me to change the floppy disk on the virtual machine better than through the script. It would be great if working with older machines that the GUI for changing the floppy disk would have been built into the Windows Virtual PC interface directly. I really rather stay away from the command it at all possible.

  • Anonymous
    October 03, 2009
    The comment has been removed

  • Anonymous
    October 04, 2009
    I have to agree with the sentiments already posted. Microsoft has taken a big step backward by not keeping floppy support in VPC. Windows XP is not the be-all end-all of backwards compatibility, and whether Microsoft wants to believe it or not, many users of virtualization technology depend on legacy support that stretches back to DOS. I am not a scripter, and I am not a programmer. I don't have the time- nor the inclination- to learn Powershell. The VBScript you provided, despite following the instructions and doggedly perusing the help files and TechNet, was a dead-end. Still no floppy in VPC. End result: My virtualization needs will now be met by VirtualBox or VMWare.

  • Anonymous
    October 08, 2009
    I also agree with the sentiments above  The omission of access to the feature in the UI only serves to lessen it's usability and versatility for many users. It will effectively promote many to seek out and use other products for their virtualization needs. I hope the Dev team rethinks it's decision to omit Floppy support from the UI and includes the feature it via patch, add-on or rerelease sp1 version

  • Anonymous
    October 19, 2009
    Thanks for the scripts.  There REALLY should be an add on to the UI as it is hard to test some things w/o the floppy (ntbackup for one!) to SCSI devices and the lot.  I am trying to mount images but I keep getting "cannot find specified file" errors no matter where I put or point my images.  I know they are valid (worked on previous version) so I'm wondering if there's a bug or if I'm doing something wrong? $> cscript Floppydrive.vbs /vm:WXP-demo /action:vfd /floppy:C:sharedflpyDOS.img

  • Anonymous
    October 19, 2009
    I have always used VirtualPC and loved it mainly for the Old Os's that I still run believe it or not.. Dos 5, OS/2 etc... and other older windows apps/games that I can't run in Vmware workstation or Dosbox. But now in Windows 7 with Windows VPC if I want to use floppy disk images.. I'm at two options... Stay with Windows XP or Vista and keep using MS VirtualPC or upgrade to win7 and use Sun's VirtualBox which has the best of both worlds of VirtualPC and VMware workstation.

  • Anonymous
    October 21, 2009
    @SirDeath, I am getting the same error.   @VirtualPC Guy,  why is this so difficult?  Why can't there be a floppy image in the product itself?  One of the reasons for virtualization is to run legacy systems.  Most legacy systems have floppy drives. Grrrrrr.

  • Anonymous
    October 21, 2009
    Here is my syntax cscript Floppydrive.vbs /vm:win31 /action: vfd /floppy:z:144upg1.img

  • Anonymous
    October 22, 2009
    Thank you for these scripts. They work fine, except I get the error "The system cannot find the file specified." if the file does not have a .vfd extension. Please document or remove this requirement.

  • Anonymous
    October 25, 2009
    The comment has been removed

  • Anonymous
    October 27, 2009
    The comment has been removed

  • Anonymous
    October 27, 2009
    Clarification Note: I have all of my floppy disks imaged with WinImage, and I occasionally need to have a physical copy of disks for the 486 computer I keep on my desk for legacy DOS stuff.

  • Anonymous
    October 31, 2009
    Thank you for these scripts. Floppy image name must be *.vfd like this cscript.exe FloppyDrive.vbs /vm:"Dos" /action:vfd /floppy:"c:Disk1.vfd"

  • Anonymous
    November 04, 2009
    Virtual PC recognizes that there is an A: floppy drive, but double-clicking the drive gives an error message "Please insert a disk into drive A:." when an installation program disk is in the floppy drive A:. I have used computers for several decades, but never written or used computer script. I need to be able to install an old legacy KeyForm Designer program on Virtual PC, but it only installs from a floppy disk. I can get the FloppyDrive.vbs script to run, but can't get the Power Shell FloppyDrive.ps1 script to run. Can you possibly provide detailed information for me, so that I can get my floppy disk drive to actually work, rather than just be recognized?

  • Anonymous
    November 04, 2009
    As usual MS missses the boat. I need either the floppy, USB, or the CD to boot to dos to run GHOST. I never understood who they beta test with. We now have a ribbon? in Word to cover a third of the screen. The need to have the ability to boot to dos for Ghost is important to a lot of users. I think it should be incorporated as a patch to VM. The CD will not boot from a ghost CD boot disk but the PC will. (tells me the CD works) Floppy is dead but we knew that.

  • Anonymous
    November 05, 2009
    Thank you but I don't want to use scripts to access floppy disks and I need folder sharing in DOS guests. I loved Virtual PC from the beginning and continue to use VPC 2007 on Windows 7. Windows Virtual PC isn't VPC anymore. It's a good loader for XP mode but it doesn't support my virtualization needs.

  • Anonymous
    November 21, 2009
    The comment has been removed

    • Anonymous
      April 09, 2016
      The comment has been removed
  • Anonymous
    November 23, 2009
    With the time that you spent on these scripts, you could have added the GUI in Virtual PC. It is really insane that Microsoft choose to make Virtual PC far less friendly to legacy systems, when the main reason people use Virtual PC is for legacy systems. How often would need to run a Windows 7 Virtual PC on a Windows 7 PC? Actually we need Virtual PC to run Windows 9x/NT/2000 and use flopply disks far more often than Vista. I sincerely hope that you will listen to your customers.

  • Anonymous
    November 23, 2009
    The comment has been removed

  • Anonymous
    November 30, 2009
    I will second and third that!!! There is no logic and no excuse for failing to provide GUI support for a floppy disk drive in Virtual PC. This type of thinking makes users shake their heads and wonder what the developers were thinking about. I don't claim to know their thoughts, but I absolutely know what they are not thinking about - the end users who upgraded to Windows 7 and were expecting Virtual PC to cover their needs for legacy programs and devices.

  • Anonymous
    November 30, 2009
    Well! Ben! We don't see any comments from you. or is this another stance by Microsoft not to do something. They couldn't automate adding a PC to the Domain or even get WAIK to work right.

  • Anonymous
    December 12, 2009
    Dear Microsoft;If it is there and you don't want it to be available for normal users (is one of Microsoft Strategic Objectives to find jobs for professionals who can wrote scripts?), why not making it part of VM configuration file, or just ask for MCP Id and email when we want to use it :)

  • Anonymous
    December 17, 2009
    What about access to older PCI cards and interfaces from Virtual PC? How can I access PCI cards that worked under XP but don't work with the old drivers under the newer VISTA and Windows 7? Thanks.

  • Anonymous
    October 05, 2010
    how did you launch this scripts??? cscript.exe FloppyDrive.vbs /vm:"Dos" /action:vfd /floppy:"c:Disk1.vfd" what is DOS ? is it DOS.vmcx ? on which path ?

  • Anonymous
    April 10, 2011
    Hi all, I'm trying to install OS/2 ;-0, but C:Admin>cscript fdd.vbs /vm:Os2 /action:vfd /floppy:c:admindisk1.imz Returns: Microsoft (R) Windows Script Host Version 5.8 Copyright (C) Microsoft Corporation. All rights reserved. Attaching c:admindisk1.imz to the floppy drive. C:Adminfdd.vbs(225, 3) (null): The system cannot find the file specified.

  • Anonymous
    June 23, 2011
    Um this does not work at all, and if we are going to run old OS's in Virtual PC wouldn't make sense to add this back, please fix this.  These scripts will not run, and I have no clue what they do, I just want to mount a flopy image in virtual PC, why is this so hard.  

  • Anonymous
    September 22, 2011
    One more thing, I said your post was quite helpful but there is a big problem here. How do I run the script? Why don't you explain how? We are not supposed to know it, so why should we struggle trying to figure it out if you could explain how to do it with a few words? It may be trivial for you but it is not trivial for most users. And even if you have already answered someone else in the comments section, that's not the right way to do things. Please, complete your article. Regards.

  • Anonymous
    October 30, 2011
    And where-and-how do you run these scripts?

  • Anonymous
    March 24, 2012
    I have waded through this whole discussion.  I also don't know how to use scripts, but need to get the virtual a: drive operational.  I have a legacy program that does an automatic read of the a: drive which asks for the disk to be inserted.  I have been able to make a: a bootable drive, but then the program residing in xp won't boot.  It needs to boot first so it can then access the premission in a:.  This is not for a game.  It is for a professional program that I have used for 10 years and need.  So, instructions on how to install the script would be very helpful.

  • Anonymous
    May 03, 2012
    So, I will just download the .zip w/ the VPC and everything will be provided?

  • Anonymous
    May 29, 2012
    The comment has been removed

  • Anonymous
    September 11, 2012
    The comment has been removed

  • Anonymous
    December 08, 2012
    Hi Thanks For The Info But I Am Having Trouble Mounting The Disks Can You Help By Any Chance? Thanks.

  • Anonymous
    May 25, 2013
    If anyone was wondering, you can still use VPC 2007 on Windows 7 if you want. This is just for people like me who like the new stuff. To do it, you just need to make sure Windows VPC is completely uninstalled. -Sidney

  • Anonymous
    October 18, 2013
    Thanks now I can install 3.1 in a VM.

  • Anonymous
    December 02, 2013
    Tried to use the vbs scripts but to no avail, it said it had worked, and using action:info it shows it's connected, but can't access it through a win xp vm. Instead I shared the USB Floppy (in windows 7, right-click in explorer, and Sharing|Advanced Sharing, check "Share this folder" and click ok (noting the name), then in your VM in My Network Places, workgroup, access your local workgroup and you will see the newly shared floppy drive).

  • Anonymous
    March 15, 2014
    No good.  I executed the PowerShell script, and the floppy inside my VM was still inaccessible.  It would be nice if this were converted into an .EXE file for either VPC or XPM, or both.

  • Anonymous
    July 14, 2014
    Excellent ! I have  lot of old photos spliced on flopped drive and splice.com won't run on Windows 7 64-bit !

  • Anonymous
    May 20, 2015
    What should I enter for my physical floppy drive is included and I can under a: directly access? "C:>cscript.exe floppydrive.vbs /vm:Disc /action:physical /floppy:a" doesn't work....