leecher1337 / ntvdmx64

Run Microsoft Windows NTVDM (DOS) on 64bit Editions
778 stars 80 forks source link

How to run (Task Scheduled) batch file NOT in legacy mode #247

Open dominicraf opened 7 months ago

dominicraf commented 7 months ago

I am using NTVDMx64 and it continues to be fantastic, many thanks. The same machine has WSLv1 (I tried WSLv2 and it broke my system, so reverted).

This machine also has a batch file (.bat) that runs from Task Scheduler. This does not need NTVDMx64 and indeed doesn't like the legacy mode, I think because, inside the code, it uses WSL. It runs perfectly from Terminal, but from a Command Prompt (cmd) - and also when run from Task Scheduler - I see error messages when it attempt to call WSL like: Unsupported console settings. In order to use this feature, the legacy console must be disabled.

What I would like is a way to force the batch file (as a Task Scheduler job) to be run through Terminal (or at any rate not using the legacy console). Is this possible? TIA

dominicraf commented 6 months ago

To answer my own question, I think it works in Task Scheduler if I specify wt.exe as the Program/Script and the actual batch file (and parameters) under 'Add arguments (optional):'

dominicraf commented 5 months ago

To update/correct my previous answer, the way to do it in Task Scheduler is actually to specify cmd.exe as the Program/Script and then something like /c "start wt -d . \path\to\my.bat /myswitch1" under 'Add arguments (optional)'

leecher1337 commented 4 months ago

Great! As a sidenote to those who are forced to have a working V2 console, you can theoretically reset HKEY_CURRENT_USER\Console ForceV2 back to 1 (Windows default). It has the huge drawback that you cannot start DOS applications in the same cmd.exe window if the current console is running as a v2 console (which would be default then), so no "seamless" integration, but it would then open a seperate console window with the DOS application that runs a V1 console. This was introduced in https://github.com/leecher1337/ntvdmx64/commit/4d67e3f70bf512c0b767652d7f0177bea0c89148 Not very convenient, so not recommended, but it should work as a fallback solution.

Your solution obviously is better.