• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 188
  • Last Modified:

How do I script a conditional change to the Registry?

Hello,

We recently imaged a number of Windows XP Professional computers that aren't showing up on the Windows Server Update Services (WSUS) console. What we need to do in a startup script is to check if the value in "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\SusClientId" is "d6fc2d8d-6276-4786-b571-9a435c6dcb14" and, if so, to run the code below.

Thanks in advance,

Thierry
net stop wuauserv
REG DELETE "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate" /v SusClientId /f
net start wuauserv
wuauclt /resetauthorization /detectnow

Open in new window

0
MrTJaume
Asked:
MrTJaume
1 Solution
 
TheBuzzManCommented:
Try this...
for /f "tokens=3" %%A in ('reg query HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate /v SusClientId') Do SET SusId=%%A
 
IF NOT %SusId%==d6fc2d8d-6276-4786-b571-9a435c6dcb14 GOTO end
echo yes
::Put your code here
PAUSE
 
:end
echo no
Pause

Open in new window

0
 
MrTJaumeAuthor Commented:
Works great! - Thanks TheBuzzMan
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now