How to cmd.exe switches (/U or /A) from INSIDE a DOS batch script?

  • Thread starter Thread starter Matt Solob
  • Start date Start date
M

Matt Solob

Ok, I could set a cmd.exe's switches when calling a batch file by entering

cmd.exe /U mybatchfile.bat

But assume I start with the default /A (ANSI) or just by double clicking on a *.bat file.
Now (after some performed statements) I want to switch output to /U (=Unicode).

Is there a way to set/modify this /U switch from INSIDE a DOS batch script?

Matt
 
Matt Solob said:
Ok, I could set a cmd.exe's switches when calling a batch file by entering

cmd.exe /U mybatchfile.bat

But assume I start with the default /A (ANSI) or just by double clicking
on a *.bat file.
Now (after some performed statements) I want to switch output to /U
(=Unicode).

Is there a way to set/modify this /U switch from INSIDE a DOS batch
script?

Matt

You need to invoke another instance of the Command Processor,
e.g. like so:
@echo off
if /i "%1"=="Unicode" goto action
echo Primary processor
cmd.exe /u /c %0 Unicode
goto :eof

:Action
echo Secondary processor
dir c:\
{Your other batch file commands go here}

By the way, DOS is an operating system introduced some thirty
years ago. It is now considered a legacy OS and is only rarely
used. DOS did not understand switches such as /U or /A. The
example I gave above is a batch file, not a DOS batch script.
 
Back
Top