我正在尝试执行一行批处理命令,如果 Key 为空,它将删除该 Key。以下是 2 个应该可行但出于某种奇怪的原因却行不通的解决方案。😩
For /f "tokens=*" %%a in ('Reg Query "HKCU\Software\RandomKey" 2^>NUL ^| FindStr /l /i /c:"\\Software\\RandomKey\\"') do (EXIT) ^& Reg Delete "HKCU\Software\RandomKey" /f 1>NUL
For /f "tokens=*" %%a in ('Reg Query "HKCU\Software\RandomKey" 2^>NUL ^| FindStr /l /i /c:"\\Software\\RandomKey\\"') do Set "FSK=1" ^& If Not "%FSK%"=="1" Reg Delete "HKCU\Software\RandomKey" /f 1>NUL