Create nul and all ascii characters with only batch

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
batmanbatman
Posts: 2
Joined: 06 May 2018 08:49

Re: Create nul and all ascii characters with only batch

#106 Post by batmanbatman » 06 May 2018 08:53

The program is not work in win10. copy file /b newfile /a is not work in win10.

carlos
Expert
Posts: 503
Joined: 20 Aug 2010 13:57
Location: Chile
Contact:

Re: Create nul and all ascii characters with only batch

#107 Post by carlos » 06 May 2018 14:49

batmanbatman wrote:
06 May 2018 08:53
The program is not work in win10. copy file /b newfile /a is not work in win10.
@batmanbatman please you can provide more details about your windows 10 version, like codepage that you use?
Last edited by carlos on 06 May 2018 14:52, edited 1 time in total.

carlos
Expert
Posts: 503
Joined: 20 Aug 2010 13:57
Location: Chile
Contact:

Re: Create nul and all ascii characters with only batch

#108 Post by carlos » 06 May 2018 14:52

On this thread (viewtopic.php?f=3&t=8513), with sst user we found that the codepage used affect the result of the .chr files. The case is when the user uses a native double byte code page like 932 or 950.

Here, is a patched version.

Code: Select all

:: This code creates one single byte. Parameter: <int>0-255
:: Teamwork of carlos, penpen, aGerman, dbenham, bluesxman, sst
:: Tested under Win2000, XP, Win7, Win8, Win10
:: Fixed issue on environments with dbcs codepage

@echo off
setlocal enableextensions
set "USAGE=echo:Usage: Supply an integer 0-255& goto :EOF"
if "%~1" equ "" %USAGE%
set /a "val=%~1" 2>nul
if "%~1" neq "%val%" %USAGE%
if %~1 lss 0    %USAGE%
if %~1 gtr 255  %USAGE%

for /f "tokens=*" %%a in ('chcp') do for %%b in (%%a) do set "cp=%%~nb"
set "options=/d compress=off /d reserveperdatablocksize=26"
set "cmd=cmd /d /c"
mode con cp select=437 >nul
if %~1 neq 26  (type nul >%~1.tmp
makecab %options% /d reserveperfoldersize=%~1 %~1.tmp %~1.chr >nul
type %~1.chr | (
(for /l %%N in (1 1 38) do pause)>nul&findstr "^">%~1.tmp)
>nul %cmd% copy /y %~1.tmp /a %~1.chr /b
del %~1.tmp
) else (%cmd% copy /y nul + nul /a 26.chr /a >nul)
mode con cp select=%cp% >nul
Last edited by carlos on 02 Sep 2018 02:51, edited 1 time in total.

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Create nul and all ascii characters with only batch

#109 Post by aGerman » 07 May 2018 01:53

@batmanbatman
To make it easier for you to provide the informations that Carlos requests you could run info.bat to be found there:
viewtopic.php?f=3&t=7420&p=49133#p49133
After you run the script an editor window will pop up. Just copy the whole content and paste it to your answer.

Steffen

batmanbatman
Posts: 2
Joined: 06 May 2018 08:49

Re: Create nul and all ascii characters with only batch

#110 Post by batmanbatman » 09 May 2018 09:04

"copy file /a newfile /b" is not work in win10.

"Not work" means:
1. after create a file by makecab.
2. The first two byte created by makecab and skip 38 byte is correct. Eg: 81 1A ....
3. copy "tempfile" /a 129.chr /b"
4. 129.chr same of tempfile. (ie. fc 129.chr tempfile is no different).
5. If Ascii is not extend ascii, everything is ok.

My computer: Microsoft Windows [ver 10.0.16299.371]. I try all code page. 437-65001. font =TT

penpen
Expert
Posts: 2009
Joined: 23 Jun 2013 06:15
Location: Germany

Re: Create nul and all ascii characters with only batch

#111 Post by penpen » 16 May 2018 04:04

Have you already tested the latest code carlos gave two posts about yours, or does the analysis base on the original version?

penpen

Post Reply