1
我想檢查一些.bat文件中的一些Windows註冊表項及其值的存在。檢查Windows批處理註冊表值
到目前爲止,我設法檢查是否存在:
@echo off
set SMB2_REGKEY=HKLM\SYSTEM\CurrentControlSet\services\LanmanWorkstation\Parameters
set SMB2_REGVAL1=FileInfoCacheLifetime
set SMB2_REGVAL2=FileNotFoundCacheLifetime
set SMB2_REGVAL3=DirectoryCacheLifetime
REM Check for presence of key first.
reg query %SMB2_REGKEY% /v %SMB2_REGVAL1% 2>nul || (echo Error! & exit /b 1)
reg query %SMB2_REGKEY% /v %SMB2_REGVAL2% 2>nul || (echo Error! & exit /b 1)
reg query %SMB2_REGKEY% /v %SMB2_REGVAL3% 2>nul || (echo Error! & exit /b 1)
我怎麼能現在檢查三個值(FileInfoCacheLifetime,FileNotFoundCacheLifetime,DirectoryCacheLifetime)的值都設置爲零?
http://stackoverflow.com/questions/11874598/querying-a-registry-key-in-a-batch-script?rq=1 – DNamto
FOR/F 「跳過= 2個令牌= 3」 % A('Reg query「HKCU \ Software \ Microsoft \ Windows \ CurrentVersion \ Explorer \ User Shell Folders」/ v「Desktop」')爲/ f「usebackq tokens = 2 * delims =」設置doc =%A %i IN('dir「%doc%」/ a/s^| findstr/i/v「\ /」')DO @echo%j&echo。 –