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

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
 
P

Pegasus \(MVP\)

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top