How do I script a conditional change to the Registry?

Posted on 2009-02-09
Last Modified: 2012-05-06

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,

net stop wuauserv

REG DELETE "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate" /v SusClientId /f

net start wuauserv

wuauclt /resetauthorization /detectnow

Open in new window

Question by:MrTJaume
    LVL 4

    Accepted Solution

    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
    echo no

    Open in new window


    Author Closing Comment

    Works great! - Thanks TheBuzzMan

    Featured Post

    Gigs: Get Your Project Delivered by an Expert

    Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

    Join & Write a Comment

    Introduction This tutorial will give you a fast look what you can do with WhizBase. I expect you already know how to work with HTML at least, and that you understand the basics of the internet and how the internet works. WhizBase is a server-s…
    This tutorial will discuss fancy secure registration forms, with AJAX technology support. In this article I assume you already know HTML and some JS. I will write the code using WhizBase Server Pages, so you need to know some basics in WBSP (you mig…
    Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
    This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now