Is it possible to make cmd.exe to parse piped batch code?
Are there ways to process piped batch code?
There seems to be conflicts between cmd interpreter syntax and batch syntax.
PS. I'm not talking about running a batch script. I'm talking about running the piped batch code.
If not:
Are there any converters that could convert batch script to a cmd.exe directly interpretable code?
Make cmd.exe parse piped batch code
Moderator: DosItHelp
Re: Make cmd.exe parse piped batch code
Hello.
Cmd.exe run code in two modes:
- interactive
- script
some differences between them: interactive not support goto labels and for variables use a single percent character (%) %a vs %%a.
Thus you can run some code as pipe to cmd.exe but with limitations, not code expected to run in batch mode, because in this case cmd will interpret it in interactive mode.
Example:
Cmd displays the windows version at the begin, because is executed in interactive mode, thus is not practical.
Cmd.exe run code in two modes:
- interactive
- script
some differences between them: interactive not support goto labels and for variables use a single percent character (%) %a vs %%a.
Thus you can run some code as pipe to cmd.exe but with limitations, not code expected to run in batch mode, because in this case cmd will interpret it in interactive mode.
Example:
Code: Select all
C:\Users\Carlos>(echo vol & exit) | cmd
Microsoft Windows [Version 10.0.xxxxx.xxx]
(c) 2019 Microsoft Corporation. All rights reserved.
C:\Users\Carlos>vol
Volume in drive C has no label.
Volume Serial Number is XXXX-XXXX
C:\Users\Carlos>
Re: Make cmd.exe parse piped batch code
All the differences between "execute a batch script" vs. "execute command lines piped/redirected to cmd.exe" are described with detail at this thread.
Antonio
Antonio