Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.
October 19, 2005
In tip 8412, I explained how deleting a registry sub-key would cause Group Policy to reinstall deployed software.
Using REG.EXE, built into Windows XP and Windows Server 2003, or from the Windows 2000 Support Tools, I have scripted DeploymentName.bat to delete the sub-key of a matching Deployment Name data value.
The syntax for using DeploymentName.bat is:
DeploymentName Name Computer
Where:
Name contains the Deployment Name string to match.Computer contains the NetBIOS computer name a the computer, like JSI009, whose registry is to be searched and altered.
DeploymentName.bat contains:
@echo offif {%2}=={} @echo Syntax: DeploymentName Name Computer&goto :EOFsetlocal ENABLEDELAYEDEXPANSIONset deploy=%1set deploy=%deploy:"=%set comp=%2set comp=%comp:"=%set comp=\%comp:=%set key="%comp%HKLMSOFTWAREMicrosoftWindowsCurrentVersionGroup PolicyAppMgmt"set fnd=HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionGroup PolicyAppMgmtfor /f "Tokens=*" %%a in ('REG QUERY %key% /S') do ( set line=%%a call set work=!line:%fnd%=! if "!line!" NEQ "!work!" set dk="%comp%!line!" set OK=N for /f "Tokens=*" %%x in ('@echo %%a ^|find /i "%deploy%" ^|find "Deployment Name"^|find "REG_SZ"') do ( set OK=Y ) if "!OK!" EQU "Y" REG DELETE !dk! /F)endlocal
You May Also Like