Skip to content

Commit 643e34d

Browse files
committed
Workaround for missing "wmic.exe" on Windows 11 24H2 installs.
1 parent f1de296 commit 643e34d

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

tests/runtest.cmd

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,9 @@
155155
set "tool1=rexx.exe"
156156
set "tool2=datetime.rexx"
157157

158+
set "did_WMIC="
159+
set "have_WMIC="
160+
158161
set "tdir="
159162
set "tname="
160163
set "noexit="
@@ -362,6 +365,43 @@
362365
::-----------------------------------------------------------------------------
363366
:LocalDateTime
364367

368+
REM "wmic" is no longer INSTALLED starting with Windows 11 24H2.
369+
REM Note however, if Windows 11 24H2 was simply UPGRADED TO from
370+
REM a previous Windows 10 or 11 installtion, then it should still
371+
REM exist. 24H2 does NOT remove it. It simply no longer INSTALLS
372+
REM it by default. So only those who do a fresh INSTALL of 24H2
373+
REM or later are affected/impacted.
374+
375+
if defined did_WMIC (
376+
377+
if not defined have_WMIC (
378+
379+
REM "wmic" doesn't exist! We have no choice but to use the
380+
REM existing builtin %date% and %time% batch variables. For
381+
REM most people using the same date/time format as the U.S.
382+
REM this will work just fine. For other countries/languages
383+
REM however, this will cause incorrectly formatted "Begin"
384+
REM and "End" and "Duration" messages. But without WMIC, we
385+
REM really have no choice in the matter! The only good news
386+
REM is that this is a purely cosmetic issue, and does not
387+
REM otherwise impact the overall functioning of the runtest
388+
REM script. It will still work fine. You will just see some
389+
REM very unusual "Begin" and "End" time messages, and your
390+
REM "Duration" message will be WILDLY inaccurate!
391+
392+
%return%
393+
)
394+
) else (
395+
396+
set "did_WMIC=yes"
397+
398+
call :fullpath "wmic.exe"
399+
400+
if defined # set "have_WMIC=yes"
401+
if not defined # %return%
402+
)
403+
)
404+
365405
setlocal
366406

367407
REM -----------------------------------------------------------------------

0 commit comments

Comments
 (0)