How can I delete a valuename under a rootkey using command file

Posted on 2009-04-17
Last Modified: 2012-05-06
I'm trying to delete the DefaultProfile name in the registry under Windows Messaging Subsystem\Profiles.  I want to delete the DefaultProfile created for Novell Groupwise without deleting any other profile names.  I'm not a vbscripter so I'm trying to do this with a batch file.  I keep getting the following error: "The sytems was unable to find the specified rergistry key or value".  Here's my code.  reg delete "HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\DefaultProfile=Novell GroupWise"

reg delete "HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\DefaultProfile=Novell GroupWise"

Open in new window

Question by:cdarney1
    LVL 67

    Accepted Solution

    If the key is string and the name is DefaultProfile, then use the first,
    Otherwise if it's indeed the Default value, then use the second
    reg delete "HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles" /v DefaultProfile
    reg delete "HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles" /ve

    Open in new window

    LVL 28

    Assisted Solution

    by:Bill Bach
    REG DELETE is documented like this:

    REG DELETE KeyName [/v ValueName | /ve | /va] [/f]

      KeyName    [\\Machine\]FullKey
        Machine  Name of remote machine - omitting defaults to the current machine.
                 Only HKLM and HKU are available on remote machines.
        FullKey  ROOTKEY\SubKey
        ROOTKEY  [ HKLM | HKCU | HKCR | HKU | HKCC ]
        SubKey   The full name of a registry key under the selected ROOTKEY.

      ValueName  The value name, under the selected Key, to delete.
                 When omitted, all subkeys and values under the Key are deleted.

      /ve        delete the value of empty value name (Default).

      /va        delete all values under this key.

      /f         Forces the deletion without prompt.


      REG DELETE HKLM\Software\MyCo\MyApp\Timeout
        Deletes the registry key Timeout and its all subkeys and values

      REG DELETE \\ZODIAC\HKLM\Software\MyCo /v MTU
        Deletes the registry value MTU under MyCo on ZODIAC

    As such, your proper command is likely going to be:

    reg delete "HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles" /v DefaultProfile

    When it works, add the /f option to skip the prompt.

    Author Comment

    Great the first option worked when I run the script manually.  (reg delete "HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles" /v DefaultProfile)

    Now to complicate matters I need to push this script out using SMS and it doesn't like the registry deletions.  It is reporting back that it can't locate the specified values.  Does anyone know how the reg key deletion needs to be written to successfully deploy with SMS?  Thanks -- Carol

    LVL 67

    Expert Comment

    I don't use SMS (much), so my unexperienced stab at this would be the quotes.
    If you have to include the entire command string in quotes, you probably need to include additional quote marks, i.e

    "reg delete ""HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging\SubSystem\Profiles"" /v DefaultProfile"
    LVL 21

    Assisted Solution

    SMS works on computers not users. The HKEY_CURRENT_USER is not the user that is logged into the machine when SMS runs it's deployment. I think it is probably the SYSTEM account. You should run your script via AD Logon Script or GPO User Logon Script.

    Here's some lines to check for Novell Groupwise default profile and delete only if it is.

    To clean out the profile add this line:

    reg delete "HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\Novell GroupWise" /f

    reg query "HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles" /v DefaultProfile | FIND /i "Novell GroupWise"
        reg delete "HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles" /v DefaultProfile /f

    Open in new window


    Author Comment

    Thanks for all the input.  What I learned is that SMS doesn't touch the HKCU so we had to create a vb script to delete the registry entries.  We will have to clean up the vbs script we are running in startup, but that isn't a hard task.  Thanks again for all the help.  -- Carol

    Author Closing Comment

    Thanks for everyone's help. - Carol

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    YESTERDAY YESTERDAY.BAT is inspired by a previous article I wrote entitled: TOMORROW.BAT ( The crux of this batch f…
    You may have already been in the need to update a whole folder stucture using a script. Robocopy does it well and even provides a list of non-updated files in a log (if asked to). Generally those files that were locked by a user or a process by the …
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    729 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

    16 Experts available now in Live!

    Get 1:1 Help Now