I currently have a working installation of MS-DOS 6.22 with Windows 3.1. I can only use Windows or DOS individually so I don't see the point of having a swap-file for Windows taking up space that can't be used for the DOS %TEMP% directory.

Let's assume that I have a separate %TEMP% directory for when Windows starts. How can I configure DOS to overwrite the Windows swap area with the contents of the %TEMP% directory?

  • 4
    I don't really think it is useful to have a swap file for DOS in a relatively modern computer that has enough memory to properly use HIMEM.SYS and EMM386
    – tofro
    Jun 18, 2017 at 12:27
  • 5
    You could delete the Windows swap file when running MS-DOS and when running Windows recreate the swap file and delete the contents of the TEMP directory. I don't think this going to worth the effort though. You'd need to have MS-DOS applications that need the extra disk space, and Windows applications that need the extra virtual memory but not the extra disk space. And be willing to put up with the longer startup times this would require.
    – user722
    Jun 18, 2017 at 20:18
  • 3
    Fragmentation could be a problem, yes, but I don't see any way else to make the disk space taken up by the Windows swap file generally available to MS-DOS applications. One thing that makes my suggestion easier to implement is that Windows 3.1 supports using a temporary swap file that it will automatically delete on exit and recreate on startup.
    – user722
    Jun 18, 2017 at 20:27
  • 1
    Is DESQView open-sourced, @RossRidge? I remember hearing that QuarterDeck (now Symantec) released it into the public domain some years back, but I can't remember if the source code was ever published. And now, of course, 10+ years later, I can't find any extant references to it online. Jun 19, 2017 at 16:15
  • 2
    @Cody DESQview was never open-sourced, just released as freeware. It used to be available from chsoft.com, but the FTP server has disappeared. oldskool.org still has it. Jun 19, 2017 at 21:06

2 Answers 2


Deleting and recreating the swap file is a really bad idea for reasons in comments.

Here follows an insane idea that would work if you pulled it off.

1) Create Permanent Swap File; ensure its contiguous. This is best done with a disk editor to ensure you also align on a cylinder boundary. Thankfully defrag.exe is sane enough to not move the windows swap file.

2) Create overlapping primary partition so that it aligns with the the swap file. I will now assume that this ends up on D:; replace script references as necessary

3) Add lines to autoexec.bat:


3) Make C:\WINDOWS\TEMP if it doesn't already exist

4) Rename win.com to runwin.com

5) Create win.bat as follows

subst D: C:\WINDOWS
subst D: /D

6) Create Y.CHR

echo Y> C:\Y.CHR

7) Reboot

The subst command can be used to mask off drives you don't want to be able to access. I've done this in the past when I had two paths to the same disk so I got two drive letters for it, and drove smartdrv.exe bonkers.

Does it work? Yes. Are you going to regret it if you ever reconfigure your windows swap file again? Yes.

  • 2
    When I read the question my first thought was to write a loadable device driver that would let you mount the swap file as an extra drive, but this is probably neater, as long as you're happy using full cylinders for the job...
    – Jules
    May 15, 2018 at 4:44
  • @Jules: That's what I thought too, but who has the expertise for that these days? A quick attempt at finding one didn't.
    – Joshua
    May 15, 2018 at 15:07

Firstly, you shouldn't do that. It will be sloooow, and won't be worth the time spent on it, mostly because old hard drives are kinda slow and not very useful in terms of using them as swap. Besides that, it may lead to slowing down the HDD or even HDD malfunction, where you may not be able to restore the data (old HDDs are mostly heavily-used ones, and making a new swapfile will make things even worse in terms of write-count).

The easiest solution would be adding something like that to the begining of AUTOEXEC.BAT:

DEL swapfile.sys

Where swapfile.sys is the name of your swapfile.

Then, the best approach is probably creating a script that will look like this:

ECHO Creating swapfile.sys, please wait...
FOR /l %i in (1,1,1000) DO ECHO. > swapfile.sys
  • 3
    "mostly because old hard drives are kinda slow and not very useful in terms of using them as swap." Yes, but old computers are also kinda slow. The relative difference between computational power and disk-access speed was much smaller in the DOS days than it is now. Also, swap space isn't used for performance reasons. It's used to allow you to do things that you couldn't otherwise use because you don't have enough physical RAM. Jun 20, 2017 at 11:00
  • @CodyGray Well, sometimes having SWAP on a slow hard drive makes performance worse(even taking other old hardware into consideration), that's what i was trying to write.
    – redsPL
    Jun 20, 2017 at 16:24
  • 4
    I wouldn't recommend creating a Windows swap in a batch file like this. Windows 3.1 can create its own temporary swap file as necessarily, while a file with a 1000 blank lines is unlikely to work as a permanent swap file. Also FOR /l won't work in MS-DOS. That, and any of the other FOR options, requires that the script be run using cmd.exe under a Windows NT based OS. You also need to use backslashes (\) instead of forward slashes (/) in your path names.
    – user722
    Jun 20, 2017 at 18:06
  • 1
    It is true that the swap file should generally be placed on the fastest disk you have available. However, it is not true that simply having a swap file makes performance slower. In a sane implementation of virtual memory, the swap file wouldn't even be used unless it was necessary because physical memory was full. (That's sort of beginning to change on modern systems, with caching and memory compression, but these ideas are very new, weren't ever used on retro systems, and wouldn't make sense there anyway for a variety of reasons.) What you were saying just isn't true. Jun 21, 2017 at 3:02
  • 1
    Therefore I don't believe having a swap file in windows 3 will ever degrade performance in real world cases: in any case where the swap file is used, you'd be seeing program segments and resources being removed from memory instead and that is likely to slow the system down still further. And once that possibility is exhausted, the system would crash. On the whole, I think having a swap file is better than not having one. (Also note that the swap file is not paging: entire segments are moved into and out of it at once. There are no page tables in win16, even when the swap file is being used.)
    – Jules
    May 15, 2018 at 13:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .