07-23-2023, 01:04 AM
I have an odd issue. I'm attempting to return the hard drive serial number from WMIC to a variable in a batch file; the line that gives me the variable is:
for /f "skip=2 tokens=2 delims=," %%a in ('wmic diskdrive get serialnumber /FORMAT:CSV') do (set harddisk=%%a)
This assigns what wmic sees as the serial number for the hard drive to a variable, the issue is that the serial number it returns is slightly off. In one example it returns:
3ZVT01H4
But the serial number on the label is:
Z3TV104H
It seems as though it is taking the actual serial number and reversing every two characters; am I typing something wrong or is this a known (but not documented anywhere) issue?
Is there a way that I can take the variable, split it into two character chunks, reverse the order of all those characters, and then put that into a variable?
for /f "skip=2 tokens=2 delims=," %%a in ('wmic diskdrive get serialnumber /FORMAT:CSV') do (set harddisk=%%a)
This assigns what wmic sees as the serial number for the hard drive to a variable, the issue is that the serial number it returns is slightly off. In one example it returns:
3ZVT01H4
But the serial number on the label is:
Z3TV104H
It seems as though it is taking the actual serial number and reversing every two characters; am I typing something wrong or is this a known (but not documented anywhere) issue?
Is there a way that I can take the variable, split it into two character chunks, reverse the order of all those characters, and then put that into a variable?