I just upgraded to 24H2 and discovered that WMIC has been removed from Windows. I now have a bunch of dead maintenance batch files. I've re-added WMIC "Feature on Demand" to one computer but that's a temporary fix. Microsoft recommends converting to Powershell but I don't know PS and am likely to make matters worse. I might be able to convert the one subroutine bat file that contains the WMIC if the other .bat files can invoke a PS script and if PS can return a "global" variable that can be picked up by a .bat file. I would rather find a function that can be used in the .bat subroutine.
The subroutine looks for all drives with labels starting with a specific string. If there is only one, it returns the drive letter in a global variable. If there is none or more than one the script complains until the user makes sure there is only one.
The chunk of code (not the entire script) containing the WMIC command is
Any recommendations for a supported alternative?
The subroutine looks for all drives with labels starting with a specific string. If there is only one, it returns the drive letter in a global variable. If there is none or more than one the script complains until the user makes sure there is only one.
The chunk of code (not the entire script) containing the WMIC command is
Code:
@echo off
SETLOCAL
:Test
:: Find a drive with label containing "SBD MM #"
:: Ignore the drive containing this script
Set LabelMask=SBD MM #
Set Drive=
Set Extra=
Set Here=%~d0%
for /f %%D in ('wmic volume get DriveLetter^, Label ^| find /I "%LabelMask%" ^| find /V "%Here%"') Do (
if defined Drive set Extra=%%D
if not defined Drive set Drive=%%D
)
If "%Drive%"=="" GoTo NoFlash
If not "%Extra%"=="" GoTo DupDrive
GoTo Return
Any recommendations for a supported alternative?
- Windows Build/Version
- Win11 Pro build 26100.4652
My Computer
System One
-
- OS
- Windows 11
- Computer type
- PC/Desktop
- Manufacturer/Model
- Microsoft
- CPU
- Intel Core i5-8400
- Motherboard
- ASUS PRIME H370-PLUS
- Memory
- 16GB
- Graphics Card(s)
- Intel UHD Graphics 630
- Sound Card
- On board
- Monitor(s) Displays
- Samsung SyncMaster 2043BWX
- Screen Resolution
- 1680 x 1050
- Hard Drives
- Samsung SSD 850 256GB
WDC 1TB NVMe
WD 3TB external USB drive
- PSU
- I don't remember
- Case
- Corsair something-or-other
- Cooling
- Air CPU + 2 case fans
- Keyboard
- DAS S Pro (Cherry Brown)
- Mouse
- Logitech USB of some sort