Running 16-bit applications on Windows 10 64-bit
Published Sep 15 2020 06:54 PM 168K Views
Microsoft

monkeys.png

 

I wrote this post as a proof of concept and as a best effort to make a 16-bit application run on Windows 10 64-bit.

 

It will be demonstrated how to use a third-part open source framework called otya128 – winevdm, how to use MSIX, UWP Execution Alias and Packaging Support Framework.

 

prohibit.png

 

Please notice that Microsoft recommends using virtualization or 32-bit machines to run 16-bit applications.

 

This post is only a proof of concept and for informational and training purposes only and are provided "as is" without warranty of any kind, whether express or implied.

 

Download the 16-bit emulator

 

As 64-bit operating system does not have support for the Windows NT DOS Virtual Machine (NTVM) system component, the first step is to download the 16-bit emulator called otya128 – winevdm that is open source and available on GitHub:

 

github.png

 

https://github.com/otya128/winevdm

 

You can clone the repository and build yourself or download the build artifact from the AppVeyor repository  https://ci.appveyor.com/project/otya128/winevdm/history

 

If you opt to download the app from the AppVeyor repository, you need to choose what build you want:

 

winevdm01.png

 

Select the job:

 

winevdm02.png

 

And finally click on artifacts to download the artifact file:

 

winevdm03.png

 

Now, all you must do is to extract the files to a folder of your preference. I will extract the files in the following folder of the root of my C drive:

 

 

 

 C:\otvdm-master-1846

 

 

 

Installing Microsoft Visual Basic 3.0 IDE on Windows 10 64-bit

 

If you try to run the Visual Basic 3 installer (setup.exe), you will receive the following message telling that the application cannot run, since it is a 16-bit application and that the NTVDM is not available.

 

this app cannot run.png

 

We need to run the otvdm.exe passing as argument the application that we want to launch, in our case, the setup.exe of Visual Basic 3.0:

 

 

 

C:\otvdm-master-1846\otvdm.exe "C:\VB\VB.EXE"

 

 

 

Notice that now the Visual Basic 3.0 16-bit installer has been successfully launched:

 

setup1.png

 

We can proceed with the installation:

 

setup2.png

 

The default destination folder is C:\VB:

 

Setup3.png

 

There are no registry keys, and all the files will be copied to the C:\VB directory:

 

setup4.png

 

Done!!!! Visual Basic is successfully installed:

 

setup5.png

 

Click on Run Visual Basic 3.0 to launch VB3 on Windows 10 64-bit:

 

vb3 on win 10.png

 

 

Notice that despite of Visual Basic 3 is available on Start menu, you can’t directly launch the app from there, as the app is 16-bit:

 

start menu.png

 

In that case you need to run the following command:

 

 

 

C:\otvdm-master-1846\otvdm.exe "C:\VB\VB.EXE"

 

 

 

Improving the app distribution and providing a better user experience through MSIX

 

Let’s see how MSIX can simplify the application deployment by keeping together the 16-bit emulator and VB3 application in a single MSIX installation file. The installation will be reduced to a single click action that will install the App in less than 10 seconds.

 

At the same time MSIX will provide a better user experience, allowing users or other apps to call the application executable, in this case, VB.EXE without having to specify the otvdm emulator. This is possible, because once packaged, the App will be access to the UWP manifest that allows us to create an execution alias.

 

MSIX Packaging Tool

The first step is to download and install the MSIX Packaging Tool, that is free and available on Microsoft Store, to allow us to package our App:

 

https://www.microsoft.com/store/productId/9N5LW3JBCXKF

 

mpt store.png

 

 

Before launching the MSIX Packaging Tool, move the emulator and VB folders to another folder, like C:\setup\:

 

setup folder.png

 

This step is need, as MSIX Packaging Tool (MPT) will monitor the changes made on the computer environment. So, as we already have VB3 installed and we don't want to install it again, I will just copy these two folders to their final destinations at the moment that the MPT will be monitoring the modifications.

 

Once installed, open the MSIX Packaging Tool and click on Application package to create a new package for the application:

 

mpt1.png

 

The MSIX Packaging Tool will monitor the changes made on the environment. To perform the packaging, it is possible to use a virtual machine or the physical machine itself to install the application.

 

The best scenario is to use a virtual machine allowing you to reproduce the same process if necessary. It is important that the machine used to install the application does not contain the applications and their previously installed components.

 

Choose the desired scenario and click the Next button:

 

mpt1a.png

 

 

In this step, the tool will verify that the MSIX Packaging Tool Driver is installed and will disable Windows Update to decrease the number of changes to the operating system:

 

mpt2a.png

 

 

Click on the Next button.

 

Only MSIX packages signed with a valid certificate can be installed on Windows 10 machines.

You can create a self-signed certificate for testing purposes, using the following PowerShell command:

 

 

 

 

function CreateCertificate($name, $path)
{

    Set-Location Cert:\LocalMachine\My
    
    New-SelfSignedCertificate -Type Custom -Subject "CN=$name" -KeyUsage DigitalSignature -FriendlyName $name -CertStoreLocation "Cert:\LocalMachine\My"

    $cert = Get-ChildItem "Cert:\LocalMachine\My" | Where Subject -eq "CN=$name"

    $pwd = ConvertTo-SecureString -String DefineTheCertificatePasswordHere@2020 -Force -AsPlainText 

    Export-PfxCertificate -cert $cert.Thumbprint -FilePath "$path.pfx" -Password $pwd
    
    Export-Certificate -Cert $cert -FilePath "$path.cer"
     
    Move-Item -Path $cert.PSPath -Destination "Cert:\LocalMachine\TrustedPeople" 

}

CreateCertificate "luisdem" "cert" 

 

 

 

 

To execute the command, open PowerShell_ISE.exe and press F5. The command creates the test certificate and copies it to the Trusted People folder.

 

It is important to notice that this test certificate should only be used to approve the application in a test environment. To distribute the application.

 

Now, that we have a certificate, we can inform the certificate to have the final MSIX package file automatically signed. It is not necessary to provide the installer file, as the tool monitors all changes made to the operating system.

 

mpt2.png

 

Click on the Next button.

 

In this step, it is necessary to provide information such as the name of the package, the description that will be displayed to the user during installation, the name of the supplier (must be the same as the certificate) and the version number. Fill in the requested information:

 

mpt3.png

 

Click on the Next button.

 

Is in this step that we need to install the application.

 

mpt5.png

 

As we already have the VB3 installed, this is the moment to moving back the emulator and VB3 folders to the drive C root:

emulator and vb3 folders.png

 

Click on the Next button only after completing the application installation and all settings.

 

On the next screen it is necessary to define which applications will be visible in the start menu.

As VB3 is a 16-bit application that depends on the 16-bit emulator, select only the otvdm.exe, as follows:

 

mpt6.png

 

Notice that is not possible to provide the arguments for the otvdm.exe, i.e.,  C:\VB\VB.EXE. For now, we can ignore the arguments as we are fix that later.

 

Follows the expected result so far:

 

mpt7.png

 

Click on the Next button.

 

The following screen is displayed at the end of the installation and asks for confirmation if the monitoring can be ended:

 

mpt7 antes.png

 

Click the Next button, as the application does not install any services:

 

mpt8.png

 

At this point, it is necessary to inform where the package will be generated, as well as it is possible to edit the package before saving it.

 

Click on the Package editor button to check the package structure, as follows:

 

mpt9.png

 

Click on Open file to check how the manifest was generated:

 

mpt9a.png

 

It is possible to edit the manifest information, such as processor architecture, application description, minimum supported version of Windows 10 and others.

 

Change the ProcessorArchitecture to “x86”, the DisplayName and Description attributes to “Microsoft Visual Basic 3.0”:

 

manifest1.png

 

Notice that the Executable attribute doesn’t have the C:\otvdm-master-1846 path, but instead it has the value VFS\AppVPackageDrive\otvdm-master-1846. The AppVPackageDrive is the folder inside the package that corresponds to the drive C root. The application will look for the file on C:\otvdm-master-1846 but it will be redirected to the folder inside the package (VFS\AppVPackageDrive\otvdm-master-1846).

 

The only problem here, is that is no possible to pass arguments in this manifest file. So, we will need to use Package Support Framework (PSF) to fix that.

 

For now, just change the Executable value path to “PsfLauncher32.exe” that is part of the PSF.

 

manifest2.png

 

We will now create an execution alias to allow launching the application by typing or calling the VB.EXE command from anywhere. To do this, add the following lines just below the line </uap:VisualElements>:

 

 

 

<Extensions>
        <uap3:Extension Category="windows.appExecutionAlias" 
                        Executable="PsfLauncher32.exe"
                        EntryPoint="Windows.FullTrustApplication">
          <uap3:AppExecutionAlias>
            <desktop:ExecutionAlias Alias="VB.EXE" />
          </uap3:AppExecutionAlias>
        </uap3:Extension>
 </Extensions>

 

 

 

Follows how the manifest file must be defined:

 

manifest3.png

 

Save and close the manifest (Notepad file) to unblock the MSIX Packaging Tool editor screen.

 

Click on Package files and check if all the files and directories listed are used by the application.

Remove unnecessary files or directories to reduce the package size:

 

mpt9b.png

 

It is at this step that we need to add the Package Support Framework files, to allow the PsfLauncher32.exe calling the emulator passing the arguments.

 

To proceed, download the PSF files (PSFBinaries.zip) available on GitHub:

 

github.png

Releases · microsoft/MSIX-PackageSupportFramework (github.com)

 

psf files.png

 

And extract the contents to a folder of your preference. I will extract to C:\PSF:

 

PSF2.png

 

In the same folder, create a config.json file with the following content:

 

 

 

{
   "applications": [
    {
      "id": "OTVDM",
      "executable": "VFS/AppVPackageDrive/otvdm-master-1846/otvdmw.exe",
      "arguments": "AppVPackageDrive/VB/VB.EXE",
      "workingDirectory": "VFS"
    }
  ]
}

 

 

 

The id corresponds to the Application Id defined in the application manifest, the executable contains the emulator path inside the package and the arguments the VB3 path inside the package.

 

Switch back to MSIX Packaging Tool. In the Package file tab, right click on Package folder and click on

 

Add file from the context menu:

 

mpt10.png

 

Add all the files that finish with 32 and the config.json files to the project:

 

mpt11.png

 

Click on the Create button to generate the package and inform where the file should be generated.

 

The following screen will display where the MSIX file was generated as well as the log file:

 

mpt12.png

 

Install the Visual Basic 3 packaged with MSIX

 

Double-click the package to install the application:

 

install.png

 

You can now launch the application directly from Start menu or typing vb.exe in a prompt command:

 

final.png

 

 

This solution is compatible with MSIX App Attach for Windows Virtual Desktop on-premises or on Microsoft Azure.

 

WVD.jpg

 

 

I hope you like it!!!

 

 

20 Comments

Good work; thanks for sharing.

 

We've used DosBox similarly to run similar ancient 16-bit software on x64, packaged in either App-V or MSIX.  This provides a fuller DOS environment that would be needed by some of the other older apps.  Using PsfTooling to inject/configure the PSF might simplify the technique here; avoiding some of the manual editing.

Microsoft

Thank you for your great feedback @TIMOTHY MANGAN !!!!

 

And thank you for having published the PsfTooling app. For sure the App can help a lot. 

 

For those that are reading this comment, PsfTooling is available at Microsoft Store and it is free: 

https://www.microsoft.com/store/productId/9NC6K0Q954JV

 

BTW... I always see your app when I search for MSIX Packaging Tool on Microsoft Store: :D 

 

psftooling.png

 

 

 

Copper Contributor

Hi,

 

thanks for this guide.
I will try to install with these instructions an old game from the 90s, which is isn't running since Windows XP, last fully functional OS for this game was WinME :)

Copper Contributor

What is 16-bit application and how is it related to Windows - the article does not explain that. I searched a bit on the web and something about Windows 3.1x comes up. This must be before Windows 7 and Windows 10?

@Anonymous2460  Ah youth!

 

Windows 3.1 was  the OS version from the 1980s and early 90s.  PCs originally had 16 bit intel processors, and 32-bit processors were the new ones.  Compatibility for running 16-bit apps on the 32-bit processors existed, but was handled by NTVDM, a kernel component which understood the hardware level requirements.  NTVDM never existed on x64 operating systems, and has been removed from the OS entirely these days.  These emulator tool provide a software emulation of what the NTVDM would have done, plus emulation of the hardware instructions using the modern instruction set.  This allows apps build as 16-bit executables to run, and often the emulator provides a full DOS emulation for the app to run in.

 

Copper Contributor

Fascinating. Thank you for the clear explanation. So it is an emulator for apps made before Windows NT but this NTVDM emulated them earlier, now it does not so this emulator does. What are these apps - are there any particularly great apps still relevant today?

There are very few 16-bit apps that folks find of interest these days.  The original poster appeared to be using it for an old game (ironically, it seems that some of the currently popular games emulate the user interfaces of those old games using modern programming models), but we run into this with businesses from time to time that have a very old app that they depend upon and will never be updated. 

 

I remember a business that rented out RVs that had 5 employees and this one 16-bit based DOS app that managed the inventory.  They all shared the one office PC they had until the hardware died.  They found a hosting provider to host it for them on RDS and we got it working on the 64-bit OS so that each employee could remotely log in from these new fangled laptops they bought, share the data, and never need to change the app.

 

We can keep these apps running, although honestly the business probably need to look to replace.

Bronze Contributor

Thank you for the proof of concept.

However, I strongly recommend people won't do that, because these are old applications and out of supported and with a lot vulnerabilities and in case user want to do that, make sure run in virtual machine or isolated environment without internet connection.

It would be good workaround for compatibility issues, but users have to look for alternatives.

Copper Contributor

Is this safe to use?

No software is completely safe from attack. 

 

The likelihood of someone target 16 bit software would be extremely low.  As in they'd first have to invent a completely new kind of virus.  Not to mention that you are running this software in an emulator that is running in a protected container, so outside programs can't modify the files.  So while I can't say it is safe, it should be very very close to it.

Microsoft

Great question @ukryan243 and thank you very much @TIMOTHY MANGAN for answering it. I couldn't have answered better.

Copper Contributor

Thank you very much for putting this guide together.

 

I have just been able to install an old piece of software that uses a 16-Bit installer on Windows 10 64-Bit!

 

 

Copper Contributor

本人在使用OTVDM來兼容16位軟體PN300終端模擬軟體FTP傳檔時出現軟體閃退的情況,望開發者能協助處理謝謝

Microsoft

Hi @SongLongTao , thank you for your great feedback! I am really glad that this post was helpful.

Copper Contributor

Thanks for this program! I have a bit of software I've been using since long ago-it does what it needs to, but is no longer being developed. This allows me to use it without having to use a VM. 

Copper Contributor

I know this is a novice question, but I am trying to run WP 6.0 and was wondering if this is the solution and if so how?

Well, that is a Windows app.  If it is 16-bit you could load a Windows 3.11 in the DOS emulator and then install it in there.  Um,  you need a license for each... 

 

It might be easier to convert the WP docs to something newer.

Copper Contributor

Well this sounds promising. I should have old licensees for these lurking around

 

in the meantime I was able to load and install WP 6.0a with winevdm

But when I ran the program I received the error of cannot load shared DLL’s

 

thoughts 

 

Copper Contributor

@luisdem Came across this post by chance, but have to say this has been a godsend. We have a product that is no longer supported, but we require for software development on Win10 opsys. Wasn't sure that it would allow the application to install, but it has, did require a slight tweek  to get it running but we are now able to move forward. Great work, many thanks!! 

Microsoft

@kwesit thank you very much for the feedback. I’m really happy that it worked!

Version history
Last update:
‎Sep 16 2020 05:07 PM
Updated by: