• Moving batch files to a Windows-11 laptop.

    From me at@my.address@is.invalid to alt.msdos.batch on Mon Jan 19 14:33:24 2026
    From Newsgroup: alt.msdos.batch


    Good morning,

    Have updated to a new computer running windows 11.
    The following bat file will not work on it.
    Lots of googling, there is no longer wmic and that I must use powershell. Looking at many posts on stackoverflow.com I still dont get it.
    Please write me something I can put in a batch file.

    Sun 01/18/2026 10:14:23 C:\tmp >cpdas aaa.txt

    Sun 01/18/2026 10:14:23 C:\tmp >copy "aaa.txt" "C:\tmp\aaa-20260118-1014-23.txt"
    1 file(s) copied.
    Sun 01/18/2026 10:14:23 C:\tmp >

    8<--- old script

    @echo off
    for /f "tokens=2 delims==" %%I in ('wmic os get localdatetime /format:list') do set datetime=%%I
    set datetime=%datetime:~0,8%-%datetime:~8,4%-%datetime:~12,2%
    @echo on

    copy "%1" "%~dpn1-%datetime%%~x1"

    8

    Thanks,


    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Nil@rednoise9@rednoise9.invalid to alt.msdos.batch on Mon Jan 19 13:07:20 2026
    From Newsgroup: alt.msdos.batch

    wmic will still work in Windows 11, they just made it an optional
    component that you can still add back. Here's how:

    https://techcommunity.microsoft.com/blog/windows-itpro-blog/how-to-install-wmic-feature-on-demand-on-windows-11/4189530


    On 19 Jan 2026, me at <my.address@is.invalid> wrote in
    alt.msdos.batch:

    Good morning,

    Have updated to a new computer running windows 11.
    The following bat file will not work on it.
    Lots of googling, there is no longer wmic and that I must use
    powershell. Looking at many posts on stackoverflow.com I still
    dont get it. Please write me something I can put in a batch file.

    Sun 01/18/2026 10:14:23 C:\tmp >cpdas aaa.txt

    Sun 01/18/2026 10:14:23 C:\tmp >copy "aaa.txt" "C:\tmp\aaa-20260118-1014-23.txt"
    1 file(s) copied.
    Sun 01/18/2026 10:14:23 C:\tmp >

    8<--- old script

    @echo off
    for /f "tokens=2 delims==" %%I in ('wmic os get localdatetime
    /format:list') do set datetime=%%I set
    datetime=%datetime:~0,8%-%datetime:~8,4%-%datetime:~12,2% @echo
    on

    copy "%1" "%~dpn1-%datetime%%~x1"

    8

    Thanks,
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From me at@my.address@is.invalid to alt.msdos.batch on Tue Jan 20 14:53:45 2026
    From Newsgroup: alt.msdos.batch

    My google research says it was dropped for security reasons. I am going to try for a powershell script.

    Thanks,


    Mon, 19 Jan 2026 13:07:20 -0500 Nil <rednoise9@rednoise9.invalid> wrote:
    | wmic will still work in Windows 11, they just made it an optional
    | component that you can still add back. Here's how:
    |
    | https://techcommunity.microsoft.com/blog/windows-itpro-blog/how-to-install-wmic-feature-on-demand-on-windows-11/4189530
    |
    |
    | On 19 Jan 2026, me at <my.address@is.invalid> wrote in
    | alt.msdos.batch:
    |
    | > Good morning,
    | >
    | > Have updated to a new computer running windows 11.
    | > The following bat file will not work on it.
    | > Lots of googling, there is no longer wmic and that I must use
    | > powershell. Looking at many posts on stackoverflow.com I still
    | > dont get it. Please write me something I can put in a batch file.
    | >
    | > Sun 01/18/2026 10:14:23 C:\tmp >cpdas aaa.txt
    | >
    | > Sun 01/18/2026 10:14:23 C:\tmp >copy "aaa.txt"
    | > "C:\tmp\aaa-20260118-1014-23.txt"
    | > 1 file(s) copied.
    | > Sun 01/18/2026 10:14:23 C:\tmp >
    | >
    | > 8<--- old script
    | >
    | > @echo off
    | > for /f "tokens=2 delims==" %%I in ('wmic os get localdatetime
    | > /format:list') do set datetime=%%I set
    | > datetime=%datetime:~0,8%-%datetime:~8,4%-%datetime:~12,2% @echo
    | > on
    | >
    | > copy "%1" "%~dpn1-%datetime%%~x1"
    | >
    | > --->8
    | >
    | > Thanks,
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Herbert Kleebauer@klee@unibwm.de to alt.msdos.batch on Tue Jan 20 16:22:40 2026
    From Newsgroup: alt.msdos.batch

    On 1/20/2026 3:53 PM, me at wrote:

    My google research says it was dropped for security reasons. I am
    going to try for a powershell script.


    Replace

    | > for /f "tokens=2 delims==" %%I in ('wmic os get localdatetime
    | > /format:list') do set datetime=%%I

    by

    set datetime=%date%%time%


    and replace 0,8 8,4 ...

    | > set datetime=%datetime:~0,8%-%datetime:~8,4%-%datetime:~12,2%

    by the correct values for your %date%%time% format.


    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From me at@my.address@is.invalid to alt.msdos.batch on Wed Jan 21 10:18:19 2026
    From Newsgroup: alt.msdos.batch


    Good morning,

    set datetime=%date%%time%
    copy "%1" "%~dpn1-%datetime%%~x1"


    01/21 2:08 C:\tmp>batch aaa.txt

    01/21 2:08 C:\tmp>set datetime=01/21/26 2:08:16.24

    01/21 2:08 C:\tmp>copy "aaa.txt" "C:\tmp\aaa-01/21/26 2:08:16.24.txt"
    The filename, directory name, or volume label syntax is incorrect.
    0 file(s) copied.


    Date is backwards, should be 20260121
    Slashes are causing it to fail
    Need white space : . to be replaced with a -

    Thanks,



    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Herbert Kleebauer@klee@unibwm.de to alt.msdos.batch on Wed Jan 21 13:19:59 2026
    From Newsgroup: alt.msdos.batch

    On 1/21/2026 11:18 AM, me at wrote:
    Good morning,

    set datetime=%date%%time%

    set datetime=01/21/26 2:08:16.24

    If this is your date/time format, try:

    :newday
    set d=%date%
    set t=%time%
    if not %d%==%date% goto :newday

    set datetime=20%d:~6,2%%d:~0,2%%d:~3,2%-%t:~0,2%%t:~3,2%%t:~6,2%
    set datetime=%datetime: =0%
    echo %datetime%






    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Kerr-Mudd, John@admin@127.0.0.1 to alt.msdos.batch on Wed Jan 21 17:21:55 2026
    From Newsgroup: alt.msdos.batch

    On Wed, 21 Jan 2026 13:19:59 +0100
    Herbert Kleebauer <klee@unibwm.de> wrote:

    On 1/21/2026 11:18 AM, me at wrote:
    Good morning,

    set datetime=%date%%time%

    set datetime=01/21/26 2:08:16.24

    If this is your date/time format, try:

    :newday
    set d=%date%
    set t=%time%
    if not %d%==%date% goto :newday

    set datetime=20%d:~6,2%%d:~0,2%%d:~3,2%-%t:~0,2%%t:~3,2%%t:~6,2%
    set datetime=%datetime: =0%
    echo %datetime%

    Or change your date format to ISO std!
    --
    Bah, and indeed Humbug.
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From me at@my.address@is.invalid to alt.msdos.batch on Thu Jan 22 14:21:40 2026
    From Newsgroup: alt.msdos.batch

    Sehr gut!

    Thank you


    Wed, 21 Jan 2026 13:19:59 +0100 Herbert Kleebauer <klee@unibwm.de> wrote:
    | On 1/21/2026 11:18 AM, me at wrote:
    | > Good morning,
    | >
    | > set datetime=%date%%time%
    | >
    | > set datetime=01/21/26 2:08:16.24
    |
    | If this is your date/time format, try:
    |
    | :newday
    | set d=%date%
    | set t=%time%
    | if not %d%==%date% goto :newday
    |
    | set datetime=20%d:~6,2%%d:~0,2%%d:~3,2%-%t:~0,2%%t:~3,2%%t:~6,2%
    | set datetime=%datetime: =0%
    | echo %datetime%
    |
    |
    |
    |
    |
    |
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Robert Roland@fake@ddress.no to alt.msdos.batch on Mon Feb 2 08:48:42 2026
    From Newsgroup: alt.msdos.batch

    On Tue, 20 Jan 2026 14:53:45 -0000 (UTC), me at
    <my.address@is.invalid> wrote:

    My google research says it was dropped for security reasons. I am going to try for a powershell script.

    PowerShell can run commands on its command line, so you can use
    PowerShell as a standalone executable, similar to how you used WMIC
    before:

    for /F %%n in ('powershell -command Get-Date -Format
    "yyyyMMdd-hhmm-ss"') do set datetime=%%n
    --
    RoRo
    --- Synchronet 3.21b-Linux NewsLink 1.2