Jump to content

.bat file with Unicode characters


Recommended Posts

Posted

I found this example and wrote something according to my needs. However, adding Unicode characters does not seem to work. Anybody know how to do it successfully?

Thanks


Posted

I don't understand the question.

It should actually have a .cmd extension, and it is so short one can post it in a codebox without problems:

@echo off
cls

TITLE:

echo 1) Mozilla Firefox
echo 2) Internet Explorer 8
echo 3) Media Player Classic
echo 4) EXIT

:a
set /p ans=Enter a number:

if '%ans%'== '1' GOTO one
if '%ans%'== '2' GOTO two
if '%ans%'== '3' GOTO three
if '%ans%'== '4' GOTO four


GOTO a

:one
cd "C:\Program Files\Mozilla Firefox"
start firefox.exe

GOTO a

:two

cd "C:\Program Files\Internet Explorer"
start iexplore.exe

GOTO a

:three
cd "C:\Program Files\K-Lite Codec Pack\Media Player Classic"
start mplayerc.exe

GOTO a

:four
exit

Can you try beetter explaining the problem (apart the fact that "TITLE:" is hardly a batch command)?

jaclaz

Posted (edited)

The thing is I want to include Cyrillic characters for explanations, which prompts to save it as Unicode. When started in Unicode, it won't work, and if I ignore the prompt and save it in ASCII with Cyrillic characters, they're shown as question marks. So, you're saying that if I save it in Unicode as a .cmd file, it will work?

To answer my own question, it doesn't.

Edited by Sp0iLedBrAt
Posted
The thing is I want to include Cyrillic characters for explanations, which prompts to save it as Unicode. When started in Unicode, it won't work, and if I ignore the prompt and save it in ASCII with Cyrillic characters, they're shown as question marks. So, you're saying that if I save it in Unicode as a .cmd file, it will work?

No, I am saying that I did not understand your question, and that the file you posted contains no UNICODE characters, nor Cyrillic ones.

Can you post an example (a short Cyrillic name/word)?

Read this in the meantime:

http://www.chem.msu.su/soft/convert/readme.txt

Get the file:

http://www.chem.msu.su/soft/convert/

and play with it a bit.

are you using (CP866) or (CP1251)?

Open a command prompt, type in it EDIT [ENTER]

and use the "DOS" editor to create/modify the batch.

jaclaz

Posted (edited)

@echo off
cls

ОДБЕРИ ПРОГРАМА ИЛИ ЗАВРШИ:

echo 1) Mozilla Firefox
echo 2) Internet Explorer 8
echo 3) Media Player Classic
echo 4) ЗАВРШИ

:a
set /p ans=Enter a number:

if '%ans%'== '1' GOTO one
if '%ans%'== '2' GOTO two
if '%ans%'== '3' GOTO three
if '%ans%'== '4' GOTO four


GOTO a

:one
cd "C:\Program Files\Mozilla Firefox"
start firefox.exe

GOTO a

:two

cd "C:\Program Files\Internet Explorer"
start iexplore.exe

GOTO a

:three
cd "C:\Program Files\K-Lite Codec Pack\Media Player Classic"
start mplayerc.exe

GOTO a

:four
exit

This, for example. BTW, I use Notepad to edit batch files, so I'm not really sure about which set I'm using.

Edited by Sp0iLedBrAt
Posted

You won't like the answer.

You need:

  • to have LucidaConsole (or another TTF font, NOT the raster one)
  • to change page to 1251
  • possibly start CMD.EXE with the /U parameter :unsure:

You need to have SEPARATE batch file and Cyrillic text.

Example copy and paste this in a Notepad or Wordpad and save as Unicode with name "choices.txt":

1 ОДБЕРИ

2 ПРОГРАМА

3 ИЛИ

4 ЗАВРШИ

Copy and paste the following in a Notepad or Wordpad and save as "plain" text with name "test.cmd"

@ECHO OFF
chcp 1251>nul
more choices.txt
for /F "tokens=1,2" %%A IN ('more choices.txt^|FIND "1"') DO ECHO %%B
for /F "tokens=1,2" %%A IN ('more choices.txt^|FIND "2"') DO ECHO %%B
for /F "tokens=1,2" %%A IN ('more choices.txt^|FIND "3"') DO ECHO %%B
for /F "tokens=1,2" %%A IN ('more choices.txt^|FIND "4"') DO ECHO %%B
chcp 437>nul

Open a command prompt, make sure that you are using Lucida Console.

Type in it:

MORE choices.txt

[ENTER]

Now run test.cmd:

TEST

[ENTER]

jaclaz

  • 11 years later...

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...