Auto-Injecting Files into an Active PCem/86Box Machine

Here's a quick-'n-dirty tool for easy, automated file transfers from a Windows host to a running machine in PCem/86Box (especially if it runs DOS).  No need to shut down/restart the emulator, to set up virtual networking, or to manually create/mount/eject floppy disk images.

It uses the disk-image approach, but does it transparently, in one click.  Useful if you tend to update sets of files very often - for example, if you do your DOS programming with native Windows tools, and switch to the emulator for quick testing and debugging.

That was my own motivation for making it: these emulators don't have DOSBox's native filesystem integration, and you can't update the HDD image without shutting down the guest machine first.  Manual fiddling with diskette images gets old real fast, when your workflow involves frequent compile/test cycles.  And a virtual network has its own limitations, especially if you're emulating something like a 640K PC/XT that only runs DOS (mTCP+FTP might be the only sane option).

In short, I wanted a way that didn't rely on any of those approaches.  After a few days of learning AHK scripting, I got together something hackish but convenient: it's made for my own use, but maybe it'll help some of you out there.


Automated Windows→PCem file transfer in action

  • PCem (tested with v15) or 86Box (tested with v2.07)
  • ImDisk Virtual Disk Driver - this takes care of the disk image automation (if you frequently deal with disk images in Windows, you should already have it).

Download PCemuFileInjector (321 KB)
(Updated 2020-09-16: download moved to GitHub)


Just run File Injector, choose the appropriate options on the right, and select (or drag & drop) the files you want to copy.

Whenever you have the emulator window open at the DOS prompt, you can simply click "Inject files", and it'll do all the work for you - including COPY/ XCOPY commands, if you select the respective option.

If you need to update and transfer the same file(s) repeatedly like I often do, you can simply keep the tool open with a fixed file list: when you click "Inject", it'll always grab the most recent copies from the host filesystem.

PCemuFileInjector screenshot

So how does this work, exactly?

  • First, the tool looks for an unused drive letter on the host, and for an active PCem/86Box window (depending on your selection); in the emulator window, it ejects any current floppy image in the chosen drive, to avoid conflicts.
  • Back on the host side, it calls ImDisk to create a new diskette image in your %TEMP% folder, format it at the selected size, and attach it to the unused drive letter.
  • If all is well, it copies your selected files/folders to the virtual disk, and releases the temporary drive letter.  Sometimes it takes a short while for all resources to unlock, so it tries to disengage politely first - if that fails 5 times, it does a forced eject.
  • Was everything copied successfully?  If so, it switches to the emulator window and mounts the temporary image.
  • If you picked the COPY or XCOPY options, it will also send the respective DOS command as keystrokes, so that means the guest machine has to be at the DOS prompt in the target directory.

It tries to give informative error messages if anything goes wrong, and there's also the "Debug output" option which shows more verbose output for troubleshooting.

  • Problems should be rare, but I've only tested this on two host machines (one running Win7, one Win10) so I don't really know - if there are any major issues, feel free to leave a comment.

  • The "Emulator" choices specify the versions I actually tested (PCem v15, 86Box v2.07), but it should work just fine with other/future versions as long as they don't change the relevant menu controls.

  • This is a public domain release. Also, no obligations or warranties are given - whatever happens, I will not be held responsible.

  • One of my work-in-progress versions somehow trigged a false positive antivirus alert, but the finished version didn't, so I hope you don't get one either.


Shawn says:

Hey, kudos to you this tool is flippin' awesome!

munizf says:

tool is awesome!

necros2k7 says:

Hi, can you update it to latest Imdisk and PCEM 16?

IIRC it should already work with PCEm 16, and the latest imdisk (at least on the official page linked here) is still the 2018 version tested before. In any case I think I'll put up the code on github soon.

Write a response:

* Required.
Your email address will not be published.