Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2009-04-17
7
Medium Priority
?
468 Views
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

0
Comment
Question by:cdarney1
7 Comments
 
LVL 67

Accepted Solution

by:
sirbounty earned 800 total points
ID: 24168852
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

0
 
LVL 29

Assisted Solution

by:Bill Bach
Bill Bach earned 400 total points
ID: 24168882
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.

Examples:

  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.
0
 

Author Comment

by:cdarney1
ID: 24170328
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

0
Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

 
LVL 67

Expert Comment

by:sirbounty
ID: 24170367
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"
0
 
LVL 21

Assisted Solution

by:AmazingTech
AmazingTech earned 800 total points
ID: 24172009
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"
IF NOT ERRORLEVEL 1 (
    reg delete "HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles" /v DefaultProfile /f
)

Open in new window

0
 

Author Comment

by:cdarney1
ID: 24226603
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
0
 

Author Closing Comment

by:cdarney1
ID: 31571490
Thanks for everyone's help. - Carol
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If like me you are one who spends a lot of time working and scripting with cmd.exe, sometimes it is handy to be able to quickly view a calendar for a given month and year. This script will quickly do just that!  Save the code posted below to a .bat …
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Suggested Courses

810 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