Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: Console App STDOUT Applications Winbatch
As we all know, it's just not possible to do it in WB; there are several well-known kludges that get you pretty close (e.g., AllocConsole/AttachConsole and conwrap).
So, as a theoretical question, is there any particular reason why WB doesn't support creation of real console apps? Note that this question is theoretical for me at the moment, since I've let my subscription lapse (just nothing new in the last few years that got me very excited). Who knows, this might get me excited again...
WIL is an interpreted scripting language where the language interpreter [the WIL run-time DLL] is being used by a GUI-mode application [WinBatch.exe]. In the case of "compiled" scripts, the .WBT file is effectively tokenized into a .WBC file which is then appended on to the end of a "stub" .EXE file that loads the WIL run-time DLL and tells it to process the embedded .WBC file that is part of the .EXE. At no point does a .WBT file get converted into native machine code instructions, and the same "stub" .EXE code is used regardless of whether WinBatch.exe is running or a "compiled" script is running.
Natively compiled applications written in VB, C++ and C# are built by a compiler that produces an executable file that is built to use either the GUI or console subsystems.
There are some major differences between applications that are written to use the console subsystem vs. the GUI subsystem.
In order for WinBatch and WIL to support running natively as a Console application while executing a script, it would be necessary to find all of the code that depends on being built in GUI mode and altering it to support both GUI and Console mode. This support would have to be implemented as a combination of several things, including building the scripting host [e.g. WinBatch.exe] such that it has 2 different .EXE files... one for the GUI subsystem and one for the Console subsystem. There may be other things necessary such as conditionally-compiled code that varies between the GUI and Console builds of the scripting host, as well as other code that may be selectively executed at run-time based on which subsystem the .EXE is running in.
Both GUI and Console applications run on top of Win32, so there's no technical reason that WinBatch & WIL couldn't be modified to support running in both GUI and Console modes. For the most part, it would simply take expending time & resources to complete the analysis, re-design and refactoring of code that would be required to implement. However, the cost of the development effort may not be offset by a ROI to justify making this a business priority.
Article ID: W17975
Filename: Console Applications with Winbatch.txt
File Created: 2009:05:07:12:11:10
Last Updated: 2009:05:07:12:11:10