Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > alt.comp.os.windows-10 > #183208

Re: what is the fastest command line copy?

Path csiph.com!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From Paul <nospam@needed.invalid>
Newsgroups alt.comp.os.windows-11, alt.comp.os.windows-10
Subject Re: what is the fastest command line copy?
Date Thu, 3 Apr 2025 03:22:13 -0400
Organization A noiseless patient Spider
Lines 179
Message-ID <vslcv8$32d9$1@dont-email.me> (permalink)
References <vsa1o9$2hf7l$1@dont-email.me> <vsctt2$1c3kf$1@paganini.bofh.team> <050kujpf36f33i4hspur5jg286m5r7fvn3@4ax.com> <vse1av$8pa5$1@dont-email.me> <vse6e0$e3ib$1@dont-email.me> <vsea99$i2o2$1@dont-email.me> <ljsmujdighbuvcltfh5kihbmnqaqqohern@4ax.com> <vsgpfb$36vg6$1@dont-email.me> <nanpujlogu6350309ttemlh3u4u3798698@4ax.com> <vsiro1$1brfi$1@dont-email.me> <vsistb$1cua7$1@dont-email.me> <vsj1h0$1hnn9$1@dont-email.me> <vsjhfm$222l7$1@dont-email.me> <vsjlp1$26ef0$1@dont-email.me> <vsjnoa$28jln$3@dont-email.me> <vsjpb2$2ac7u$1@dont-email.me> <vsjvjj$2gj8d$1@dont-email.me>
MIME-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding 8bit
Injection-Date Thu, 03 Apr 2025 09:22:17 +0200 (CEST)
Injection-Info dont-email.me; posting-host="a00b16899f1b6037f698b7dfc519833e"; logging-data="100777"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+ZygiCsLgGV96Bair9+cFPtTErH3ynUDc="
User-Agent Ratcatcher/2.0.0.25 (Windows/20130802)
Cancel-Lock sha1:bb4B7OvMb5VdHqddbJAv3Nkr1sk=
Content-Language en-US
In-Reply-To <vsjvjj$2gj8d$1@dont-email.me>
Xref csiph.com alt.comp.os.windows-11:18217 alt.comp.os.windows-10:183208

Cross-posted to 2 groups.

Show key headers only | View raw


On Wed, 4/2/2025 2:27 PM, R.Wieser wrote:
> Paul,
> 
> [quote]
>> In scripting, you have to be careful with "volatile" items
>> like an %errorlevel% . They must be copied before they
>> are lost,
>  ...
>> D:\>paulcopy64 a b
>> Error opening source file: No such file or directory
>>
>> D:\>dir
>> Volume in drive D
>>
>> Directory of D:\
>> Tue, 03/18/2025  09:56 AM           252,122 paulcopy64.exe
>>
>> D:\>echo %errorlevel%
>> 0                              # Oops! I lost my copy failure code.
> 
> On the other hand, you should not contuinue (after the failed copy) when
> you are getting an error ...
> [/quote]
> 
>> Um, that was a code snippet.
> 
> I seem to be missing something..  Could you point out your "code snippet" in
> the above ?
> 
> Yes, thats quoted from my reply to you talking about %errorlevel% losing its
> failure code.
> 
> Regards,
> Rudy Wieser
> 

So as it turns out, it's more complicated than I thought. There is ERRORLEVEL
and %errorlevel% does not actually exist. But there is a potential fallback
behavior for creating it anyway.

https://devblogs.microsoft.com/oldnewthing/20080926-00/?p=20743

   "Now, it does happen to be the case that if command extensions are enabled and you say %ERRORLEVEL%,
    then the command processor first looks for an environment variable called ERRORLEVEL, and if it
    can’t find one, then it replaces %ERRORLEVEL% with the current value of the internal error level value.
    It’s a fallback step, in the same way that your neighbor is a fallback delivery location if you aren’t home.
    If you file a change-of-address form for yourself, that doesn’t affect packages sent to your neighbor. "

*******

D:\>paulcopy64 a b
Error opening source file: No such file or directory

D:\>if ERRORLEVEL 1 echo Does this print?
Does this print?

D:\>paulcopy64 a b
Error opening source file: No such file or directory

D:\>if ERRORLEVEL 0 echo Does this print?
Does this print?

So something is wrong here.

D:\>paulcopy64 a b
Error opening source file: No such file or directory

D:\>echo %errorlevel%
1

If I create an "a" file, we can try again. This is to check
that the value is actually coming from the program.

D:\>paulcopy64 a b
file_size = 0
Prepare buffer...
Starting run...
some_size read  = 0
Read  0 bytes in 000.001292 seconds
some_size write = 0
Wrote 0 bytes in 000.001744 seconds
File copied successfully.


D:\>echo %errorlevel%
0

I guess the only way to prove something works then, is to
write a script and expect different behavior inside ??? I don't
have the key mentioned here, there is no HKCU Command Processor in W11.

   HKCU\Software\Microsoft\Command Processor
       EnableExtensions DWORD 1               # enabled

   cmd /y disables command extensions for this cmd session
   cmd /x enables command extensions for this cmd session

It turns out the key does already exist, but it is at this
location, making it machine wide and it is enabled.

   HKLM\Software\Microsoft\Command Processor
       EnableExtensions DWORD 1               # enabled

Now I can run my script

@;echo off
paulcopy64 a b
if ERRORLEVEL 1 echo The result is 1 and this is bad

With the "a" file missing, it prints

D:\>myscript.bat
Error opening source file: No such file or directory
The result is 1 and this is bad

With the "a" file present, it does not print, at the script level,
so ERRORLEVEL is something other than 1.

D:\>myscript.bat
file_size = 0
Prepare buffer...
Starting run...
some_size read  = 0
Read  0 bytes in 000.001170 seconds
some_size write = 0
Wrote 0 bytes in 000.001974 seconds
File copied successfully.

If I change the script to

@;echo off
paulcopy64 a b
echo %errorlevel%

the value is falling through as Raymond explained.

D:\>myscript.bat
Error opening source file: No such file or directory
1

If I change the script to

@;echo off
paulcopy64 a b
if "%errorlevel%"=="1" echo The result is 1

and run with no "a" file

D:\>myscript.bat
Error opening source file: No such file or directory
The result is 1

Exciting. Let's see what this does.

@;echo off
set globalvar=The value is
paulcopy64 a b
set globalvar=%globalvar% %errorlevel%
REM The dot removes the leading space character
echo.%globalvar%
echo This is a test

gives an output of

D:\>myscript.bat
Error opening source file: No such file or directory
The value is 1
This is a test

And this is why I don't write batchscript. It's
about as much fun as writing in assembler.

Ref: Would not have got this far, without a web page.
     It's still like pulling teeth.
https://www.tutorialspoint.com/batch_script/batch_script_quick_guide.htm

   Paul

Back to alt.comp.os.windows-10 | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: what is the fastest command line copy? Dual Boot Windows <invalid@invalid.invalid> - 2025-03-31 02:12 +0100
  Re: what is the fastest command line copy? Steve Hayes <hayesstw@telkomsa.net> - 2025-03-31 04:43 +0200
    Re: what is the fastest command line copy? Paul <nospam@needed.invalid> - 2025-03-31 00:47 -0400
      Re: what is the fastest command line copy? Steve Hayes <hayesstw@telkomsa.net> - 2025-03-31 11:06 +0200
      Re: what is the fastest command line copy? Stan Brown <the_stan_brown@fastmail.fm> - 2025-03-31 12:10 -0700
      Re: what is the fastest command line copy? "Jonathan N. Little" <lws4art@gmail.com> - 2025-04-01 18:56 -0400
    Re: what is the fastest command line copy? Newyana2 <newyana@invalid.nospam> - 2025-03-31 08:21 -0400
      Re: what is the fastest command line copy? "R.Wieser" <address@is.invalid> - 2025-03-31 15:47 +0200
        Re: what is the fastest command line copy? Newyana2 <newyana@invalid.nospam> - 2025-03-31 10:54 -0400
          Re: what is the fastest command line copy? Andy Burns <usenet@andyburns.uk> - 2025-03-31 15:59 +0100
          Re: what is the fastest command line copy? "R.Wieser" <address@is.invalid> - 2025-03-31 17:32 +0200
          Re: what is the fastest command line copy? Steve Hayes <hayesstw@telkomsa.net> - 2025-04-01 07:00 +0200
            Re: what is the fastest command line copy? "R.Wieser" <address@is.invalid> - 2025-04-01 09:11 +0200
            Re: what is the fastest command line copy? Paul <nospam@needed.invalid> - 2025-04-01 03:44 -0400
            Re: what is the fastest command line copy? Newyana2 <newyana@invalid.nospam> - 2025-04-01 09:26 -0400
              Re: what is the fastest command line copy? Steve Hayes <hayesstw@telkomsa.net> - 2025-04-02 08:50 +0200
                Re: what is the fastest command line copy? Paul <nospam@needed.invalid> - 2025-04-02 04:15 -0400
                Re: what is the fastest command line copy? "R.Wieser" <address@is.invalid> - 2025-04-02 10:35 +0200
                Re: what is the fastest command line copy? Paul <nospam@needed.invalid> - 2025-04-02 05:54 -0400
                Re: what is the fastest command line copy? "R.Wieser" <address@is.invalid> - 2025-04-02 16:15 +0200
                Re: what is the fastest command line copy? Paul <nospam@needed.invalid> - 2025-04-02 11:40 -0400
                Re: what is the fastest command line copy? "R.Wieser" <address@is.invalid> - 2025-04-02 18:13 +0200
                Re: what is the fastest command line copy? Paul <nospam@needed.invalid> - 2025-04-02 12:41 -0400
                Re: what is the fastest command line copy? "R.Wieser" <address@is.invalid> - 2025-04-02 20:27 +0200
                Re: what is the fastest command line copy? Paul <nospam@needed.invalid> - 2025-04-03 03:22 -0400
                Re: what is the fastest command line copy? "R.Wieser" <address@is.invalid> - 2025-04-03 13:10 +0200
                Re: what is the fastest command line copy? Newyana2 <newyana@invalid.nospam> - 2025-04-02 07:57 -0400
                Re: what is the fastest command line copy? "R.Wieser" <address@is.invalid> - 2025-04-02 16:19 +0200
                Re: what is the fastest command line copy? Newyana2 <newyana@invalid.nospam> - 2025-04-02 11:04 -0400
                Re: what is the fastest command line copy? Paul <nospam@needed.invalid> - 2025-04-02 12:04 -0400
                Re: what is the fastest command line copy? "R.Wieser" <address@is.invalid> - 2025-04-02 18:06 +0200
                Re: what is the fastest command line copy? Frank Slootweg <this@ddress.is.invalid> - 2025-04-02 12:41 +0000
                Re: what is the fastest command line copy? Paul <nospam@needed.invalid> - 2025-04-02 12:15 -0400
                Re: what is the fastest command line copy? Frank Slootweg <this@ddress.is.invalid> - 2025-04-02 17:36 +0000
                Re: what is the fastest command line copy? Stan Brown <the_stan_brown@fastmail.fm> - 2025-04-02 10:50 -0700
                Re: what is the fastest command line copy? Steve Hayes <hayesstw@telkomsa.net> - 2025-04-03 05:24 +0200
                Re: what is the fastest command line copy? Democrat <Democrat@invalid.invalid> - 2025-04-03 06:00 +0000
                Re: what is the fastest command line copy? "R.Wieser" <address@is.invalid> - 2025-04-03 08:39 +0200
                Re: what is the fastest command line copy? Steve Hayes <hayesstw@telkomsa.net> - 2025-04-03 15:55 +0200
                Re: what is the fastest command line copy? Frank Slootweg <this@ddress.is.invalid> - 2025-04-03 15:06 +0000
                Re: what is the fastest command line copy? Steve Hayes <hayesstw@telkomsa.net> - 2025-04-04 13:55 +0200
                Re: what is the fastest command line copy? Frank Slootweg <this@ddress.is.invalid> - 2025-04-04 12:11 +0000
                Re: what is the fastest command line copy? Don_from_AZ <djatechNOSPAM@comcast.net.invalid> - 2025-04-04 10:32 -0700
                Re: what is the fastest command line copy? Steve Hayes <hayesstw@telkomsa.net> - 2025-04-05 05:20 +0200
                Re: what is the fastest command line copy? T <T@invalid.invalid> - 2025-04-05 00:44 -0700
                Re: what is the fastest command line copy? Daniel70 <daniel47@eternal-september.org> - 2025-04-06 20:20 +1000
                Re: what is the fastest command line copy? "Kerr-Mudd, John" <admin@127.0.0.1> - 2025-04-06 21:15 +0100
                Re: what is the fastest command line copy? Newyana2 <newyana@invalid.nospam> - 2025-04-04 08:49 -0400
                Re: what is the fastest command line copy? Steve Hayes <hayesstw@telkomsa.net> - 2025-04-05 05:29 +0200
                Re: what is the fastest command line copy? Newyana2 <newyana@invalid.nospam> - 2025-04-05 08:26 -0400
                Re: what is the fastest command line copy? Paul <nospam@needed.invalid> - 2025-04-05 00:37 -0400
                Re: what is the fastest command line copy? Newyana2 <newyana@invalid.nospam> - 2025-04-05 08:18 -0400
                Re: what is the fastest command line copy? Char Jackson <none@none.invalid> - 2025-04-03 11:00 -0500
                Re: what is the fastest command line copy? Newyana2 <newyana@invalid.nospam> - 2025-04-02 07:53 -0400
                Re: what is the fastest command line copy? "R.Wieser" <address@is.invalid> - 2025-04-02 16:26 +0200
                Re: what is the fastest command line copy? Newyana2 <newyana@invalid.nospam> - 2025-04-02 11:03 -0400
                Re: what is the fastest command line copy? "R.Wieser" <address@is.invalid> - 2025-04-02 18:04 +0200
                Re: what is the fastest command line copy? Paul <nospam@needed.invalid> - 2025-04-02 12:36 -0400
                Re: what is the fastest command line copy? Newyana2 <newyana@invalid.nospam> - 2025-04-02 13:07 -0400
                Re: what is the fastest command line copy? Paul <nospam@needed.invalid> - 2025-04-03 04:14 -0400
                Re: what is the fastest command line copy? Newyana2 <newyana@invalid.nospam> - 2025-04-03 08:40 -0400
                Re: what is the fastest command line copy? Stan Brown <the_stan_brown@fastmail.fm> - 2025-04-02 10:43 -0700
                Re: what is the fastest command line copy? Char Jackson <none@none.invalid> - 2025-04-02 18:59 -0500
                Re: what is the fastest command line copy? Stan Brown <the_stan_brown@fastmail.fm> - 2025-04-02 11:11 -0700
        Re: what is the fastest command line copy? knuttle <keith_nuttle@yahoo.com> - 2025-03-31 10:59 -0400
          Re: what is the fastest command line copy? "R.Wieser" <address@is.invalid> - 2025-03-31 17:26 +0200
            Re: what is the fastest command line copy? Newyana2 <newyana@invalid.nospam> - 2025-03-31 13:05 -0400
              Re: what is the fastest command line copy? "R.Wieser" <address@is.invalid> - 2025-03-31 20:18 +0200
                Re: what is the fastest command line copy? Newyana2 <newyana@invalid.nospam> - 2025-03-31 14:43 -0400
    Re: what is the fastest command line copy? Stan Brown <the_stan_brown@fastmail.fm> - 2025-03-31 13:40 -0700
  Re: what is the fastest command line copy? T <T@invalid.invalid> - 2025-03-30 23:03 -0700
  Re: what is the fastest command line copy? T <T@invalid.invalid> - 2025-03-30 23:43 -0700
  Re: what is the fastest command line copy? T <T@invalid.invalid> - 2025-04-01 02:01 -0700

csiph-web