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.

Chris says:

Error with PCemu 17:

ImDisk virtual disk driver not installed or not in path.

@Chris: that message is unrelated to the emulator version - see Requirements section, and ensure that ImDisk is installed correctly and accessible in PATH (if you can run "imdisk" from a command prompt and get the help text, you should be good).

tom says:

very good

dAcHEF36 says:

This doesn't seem to be working with 86Box 3253 build. Sometimes, before it copies, the letter "E" is inserted, which kills the copy command in DOS 6.22. That, or after the disk image is attached the app doesn't respond. I must run it again. It may take a few tries to get things to work.

I've noticed that certain keyboard layouts that aren't US English (either in the host or in the emulator) can muck up the copy command, since it's sent over as a keypress sequence. Not sure what could be done about that, but I'll try to see if I get any reproducible issues with that 86Box build.

Re: app doesn't respond, do you mean the file injector or the emulator? If it's the emulator, does that ever happen if you mount disk images the 'normal' way? Anything in Debug Output maybe?

Jared says:

Like with anything I do, there is an error with 86Box 3.1 running Windows 98, which tells me that I am at the top directory and cannot go any further. Debug gives me an access denied error. Oh, whatever shall I do?

Skurk says:

Hello! I was thrilled to find this tool, but unfortunately it doesn't work for me.
I am getting the error message "Cannot find active emulator window".
I am using 86Box 3.7.1 [build 4032] and am assuming that something might have changed in a later version? The window is definitely active!
Thank you for any help!

Lee says:

I'm having the same problem as Skurk, "Cannot find active emulator window". 86Box 3.7.1 [build 4032] is running.

@Skurk, Lee: yep, seems like recent builds of 86box have changed things around- thanks for reporting. I'll see if I can fix that in the near future.

Paul says:

Add option to mount image / inject files using CD Drive, so it allows for larger file sizes.

vvv says:

I gotta say, you sure go above and beyond on trying to make things generally useful instead of just solving your own instance. If it were me, the thing would just periodically poll some hardcoded folder for files and operate on them without any helpful UI or settings...

But is there even a reason to be copying files out of the diskette instead of just working straight inside it? And why couldn't this work with hdds? Unless you loaded smartdrv or something DOS should not have any caching to prevent your changes from being seen. Or are the emulators themselves adding caching or keeping the image locked? If it's the latter, perhaps a pause/unpause of the emulator could help, or if not - a new feature request to their devs is in order...

Write a response:

* Required.
Your email address will not be published.