I want to get HResult from %errorlevel%. I tried to install a wrong product key using this command
wmic path SoftwareLicensingService WHERE (Version is not null) call InstallProductKey ProductKey='xyz'>nul 2>&1
The %errorlevel% now return -1073418160. Convert it to hex and add "0x" before it. I got 0xC004F050
I tried to use this command: powershell "\"0x{0:X}\" -F %errorlevel%
. But I have chcp 65001
in the first line. Therefore, my console is not flat after running. Is there anyway to convert from %errorlevel% to HResult without executing Powershell?
"Xin chào" is a traditional greeting of Vietnamese people
from DosTips:
call cmd /c exit /b -1073418160
echo %=exitcode%
Result:
C004F050
so you probably want:
call cmd /c exit /b %errorlevel%
echo 0x%=exitcode%
User contributions licensed under CC BY-SA 3.0