Regfile to delete registry value (dword) not working?

For the life of me I can't figure out why I can't delete this value.

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SharedDlls]
"C:\CMC\CMC_ENet.dll"=-

the value is a DWORD, i'm wondering if there is anything I have to specify inorder to delete it? I tried various tweaks to the code and haven't been able to come up with nothing yet.
troehmAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

BillDLCommented:
There are two issues, but one is not visible from your text:

1. You MUST leave at least one blank line after the last line of text in the file, or it will not work.  Exporting to a *.reg file from Regedit always creates 2 blank lines, which is what I always leave.

2. Single backslashes are not permitted unless forming part of the key name, or acting as a control character just before a value that contains quotation marks besides the ones that will be created on export.  They are converted to double backslashes like this:

Windows Registry Editor Version 5.00
 
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SharedDLLs]
"C:\\CMC\\CMC_ENet.dll"=-

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
BillDLCommented:
Here's what I was meaning when I spoke about the use of a single backslash where quotation marks in the Value or ValueData exist:

@="\"C:\\Program Files\\Internet Explorer\\IEXPLORE.EXE\" \"%1\""

Because the folder Program Files has a space, the path to IExplore was enclosed in quotation marks.  Similarly, because the path to the file that it would open (%1) is not known, it too is surrounded by quotation marks in case it has spaces.  The actual command would look like this, and would be what was entered manually into Regedit:

"C:\Program Files\Internet Explorer\IEXPLORE.EXE" "%1"

When exporting the key, and is also what would be expected if to be successfully imported, Regedit applies its own quotation marks around the whole Value and the ValueData (the command here).  The exception is the [Default] StringValue which isn't ever quoted and is represented by @=

To differentiate between the OUTSIDE quotation marks and the INNER ones, single backslashes are placed immediately before the INSIDE quotation marks so that Regedit knows the difference between them.

Superfluous to your needs in this case of course, because your Value doesn't contain spaces, but maybe some day you may need to know this info.
0
BillDLCommented:
Another thing, in a Windows XP batch file, or at the command prompt, you have a dangerous command at your disposal.  The  REG  command has a set of switches shown by typing  reg /?  and there are a further set of sub-switches that you can type, eg.
reg delete /?
REG /?
 
REG Operation [Parameter List]
 
  Operation  [ QUERY   | ADD    | DELETE  | COPY    |
               SAVE    | LOAD   | UNLOAD  | RESTORE |
               COMPARE | EXPORT | IMPORT ]
 
Return Code: (Except of REG COMPARE)
 
  0 - Succussful
  1 - Failed
 
For help on a specific operation type:
 
  REG Operation /?
 
Examples:
 
  REG QUERY /?
  REG ADD /?
  REG DELETE /? <--------------- **
  REG COPY /?
  REG SAVE /?
  REG RESTORE /?
  REG LOAD /?
  REG UNLOAD /?
  REG COMPARE /?
  REG EXPORT /?
  REG IMPORT /?
 
 
REG DELETE /?
 
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 <no name>
  /va        delete all values under this key
  /f         Forces the deletion without propmt
 
Examples:
 
  REG DELETE HKLM\Software\MyCo\MyApp\Timeout
    Deletes the registry key Timeout and its all subkeys and values

Open in new window

0
troehmAuthor Commented:
Thanks so much, very good info to know. Exactly what I needed.
0
BillDLCommented:
Thank you troehm.

I wonder who coded the WinXP SP2 version of C:\Windows\System32\Reg.exe
2 spelling mistakes:
"Succussful" instead of "Successful"
"propmt" instead of "prompt"
and a grammatical error:
"Return Code: (Except of REG COMPARE)" instead of "Return Code: (Except for REG COMPARE)"
slipped past.

:-)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Utilities

From novice to tech pro — start learning today.