Using Floppy Disks with Windows Virtual PC

Using Floppy Disks with Windows Virtual PC

Rate This
  • Comments 41

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

Attachment: Floppy Drive Scripts.zip
Leave a Comment
  • Please add 3 and 4 and type the answer here:
  • Post
  • And where-and-how do you run these scripts?

  • 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.

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

  • I'm using the PowerShell script and wanted to clarify some things for others who might stumble upon this blog entry.  In order to successfully mount diskettes with these scripts, the images must have a file extension of VFD.  Images made from programs like WinImage, that use the IMG file extension, will work once you rename them to *.VFD

    Also, you are able to 'hot swap' diskette images by simply mounting the new image from the script.  Here's the syntax I am using on a virtual machine named "Windows NT 4 Workstation"

    PS C:\temp> ./floppydrive.ps1 -vmName "Windows NT 4 Workstation" -action vfd -floppy c:\temp\DISK5.vfd

    The script then responds "Attaching  c:\temp\DISK5.vfd  to the floppy drive." and I'm able to access the image from the virtual machine.

  • Thank you for providing these. But I must agree with everyone else that omitting the GUI elements for the feature was a very bad decision. This age-old assumption that too many features will scare off inexperienced users... it's idiotic. You can see the trend in many applications. Software gets dumbed down more and more, until those who really use it can no longer do the stuff they want with it. You seem to be under the assumption that the only users who need something like floppy support in Virtual PC are those who are experienced with scripting etc.; first, the comments on this post prove that assumption wrong, and second, believe it or not even experienced users sometimes prefer to do something with 2 mouse clicks rather than a shell.

    VPC's interface has already been dumbed down a lot. Most users, those you're concerned about in particular, will never even get to see the configuration dialogue, so I don't see how adding a Floppy tab to the 15 existing tabs would have made things so much worse. And if you were still concerned, you could have mad a Beginner/Advanced GUI option like so many other applications do.

    But this is far from the only feature that has been removed, and Microsoft has long made clear their intention to kill off Virtual PC, by gradually removing everything that made it useful for running pre-XP legacy systems. It's also a repeated pattern that bad decisions by MS management have to be assuaged by dedicated employees in their blogs (where I will add that I applaud MS for letting them do that; not many tech companies are that liberal). But for legacy system virtualization, the dice have been thrown. Four options I can offer are:

    - Downgrade to the much more powerful VirtualPC 2007 or 2004.

    - Upgrade to VMware Player (it's free).

    - Upgrade to Oracle VirtualBox (it's free).

    - Upgrade to Bochs (it's free).

  • Hi Thanks For The Info But I Am Having Trouble Mounting The Disks Can You Help By Any Chance?

    Thanks.

  • 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

  • Thanks now I can install 3.1 in a VM.

  • 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).

  • 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.

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

Page 3 of 3 (41 items) 123