Serious cmd.exe module issues

Open forum for end-user questions about Wine. Before asking questions, check out the Wiki as a first step.
Forum Rules
Locked
Psycho-A
Newbie
Newbie
Posts: 4
Joined: Sun Jun 02, 2019 7:36 am

Serious cmd.exe module issues

Post by Psycho-A »

Hello everyone community's member! I'm new here, but I really want to share my observations on using Wine.

I'm always noticing that many operations in .bat/.cmd user scripts performs incorrectly with current (v4.x stable) native cmd.exe module. Maybe there's no such an objective to have 100% compatibility with original command processor, but let's be consistent: people who set "Windows version" to "Windows 7" (or different) in WineCfg will expect that command line will behave like in selected OS too. Moreover, incorrect executing batch scripts may even harm user's data in cases where he doesn't even expects that.

1) Commands "mode" and "chcp" are not supported, although they play important role in some cases.

2) Constructions like

Code: Select all

for %%m in (blah blah) do if exist %%m (
    do something...
)
returns syntax error with "(" or tries to read "do something" first, although

Code: Select all

for %%m in (blah blah) do (if exist %%m (
    do something...
))
already works correctly.

Also, there's technically valid code that doesn't want to work in wine too, returning
Can't find "%LauncherLoc%_%~l.ini" and "do " is not a program or correct command.

Code: Select all

set AppLanguage=rus
set LauncherLoc=%cd%\launcher
for %%l in ("eng" "%AppLanguage%") do (
if exist "%LauncherLoc%_%%~l.ini" (
for /f "usebackq eol=; delims== tokens=1,*" %%a in ("%LauncherLoc%_%%~l.ini") do (
	call set "%%~a=%%~b"
)))
3) Empty lines in reading file (f.e. *.ini in example above) may be considered as empty commands and throw error, although they just must be skipped in normal command processor.

4) Console window doesn't clear itself correctly with "cls" command and draws old text behind the new one.

5) Command "start /b ..." (run external file inside of current console window) doesn't work as intended and runs external console window.

Installing cmd.exe from winetricks or copying cmd.exe from Windows XP over the original one helps with 2) and 3), but not with others. To make "mode" and "chcp" commands work, we also need to copy chcp.com, mode.com, ulib.dll and ureg.dll from Windows XP. Also, CLS still doesn't normally work. Why the native cmd module is still so incomplete?
Psycho-A
Newbie
Newbie
Posts: 4
Joined: Sun Jun 02, 2019 7:36 am

Re: Serious cmd.exe module issues

Post by Psycho-A »

Continuing my observations...

6) if Setlocal EnableDelayedExpansion is enabled, and some of for cycle variable used inside of target variable, then it doesn't expand in IF expression. F.e.
Set Var1=Blah blah...
for /l %%n in (1,1,9) do (

)
Psycho-A
Newbie
Newbie
Posts: 4
Joined: Sun Jun 02, 2019 7:36 am

Re: Serious cmd.exe module issues

Post by Psycho-A »

Continuing my observations...

6) if Setlocal EnableDelayedExpansion is enabled, and some of for cycle variable used inside of target variable, then it doesn't expand in IF expression. F.e.

Code: Select all

Set Var1=Blah blah...
for /l %%n in (1,1,9) do (
    if exist "!Var%%n!" (
        rem do something...
    )
)
variable !Var%%n! won't expand (although in Windows 2000-10 do).

7) Transfering "> nul" over the () brackets reports and error: "" is not an appication or command. Example:

Code: Select all

if exist "File.ext" (
    reg export "HKLM\Software\AppName"
    reg delete "HKLM\Software\AppName" /f
)> nul
8) MOVE command doesn't normally work with /y key and doesn't overwrite target file. Also it doesn't work on transferring files between disk partitions.

9) Variable of FOR cycle doesn't expand to next FOR /f cycle if it's used for reading files. F.e. in

Code: Select all

for %%m in (eng rus ita) do (
for /f "usebackq delims== tokens=1,2" %%a in ("SomeFile_%%m.txt") do (
    rem do something...
))
cmd returns the error of missing "SomeFile_%%m.txt" file instead of read "SomeFile_rus.txt" file.

10) If we're specifying EOL=# in some file in FOR /f cycle, then empty lines will be read too, although they should normally not.

Maybe it's even not full list of bugs, although, figuring all of that out, I could adapt my batch scripts to be compatible with Wine console.
User avatar
DarkShadow44
Level 8
Level 8
Posts: 1207
Joined: Tue Nov 22, 2016 5:39 pm

Re: Serious cmd.exe module issues

Post by DarkShadow44 »

Did you report those issues as bugs already?
Psycho-A
Newbie
Newbie
Posts: 4
Joined: Sun Jun 02, 2019 7:36 am

Re: Serious cmd.exe module issues

Post by Psycho-A »

DarkShadow44 wrote:Did you report those issues as bugs already?
No. How can I do that? I'm newbie here amd just registered here after my Wine experience under Linux Mint 19.1...
User avatar
DarkShadow44
Level 8
Level 8
Posts: 1207
Joined: Tue Nov 22, 2016 5:39 pm

Re: Serious cmd.exe module issues

Post by DarkShadow44 »

The bugtracker is here: https://bugs.winehq.org/

You just need an account, then you can create bug reports. Those will get looked at by the wine devs, the forums are mostly for user help, devs don't necessarily patrol them.
When creating a bugreport, make sure you fill us in with as much information as you can, and please also link them here. :)
Locked