Link to home
Start Free TrialLog in
Avatar of troehm
troehm

asked on

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.
ASKER CERTIFIED SOLUTION
Avatar of BillDL
BillDL
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
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

Avatar of troehm
troehm

ASKER

Thanks so much, very good info to know. Exactly what I needed.
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.

:-)