+ Post New Thread
Results 1 to 15 of 15
Windows 7 Thread, Deleting registry entries with batch file in Technical; How do you do this... This is my batch and it does not seem to want to work: regedit /l:c:\windows\system.dat ...
  1. #1

    Join Date
    May 2012
    Posts
    290
    Thank Post
    0
    Thanked 1 Time in 1 Post
    Rep Power
    0

    Deleting registry entries with batch file

    How do you do this...

    This is my batch and it does not seem to want to work:

    regedit /l:c:\windows\system.dat /r:c:\windows\user.dat /d HKEY_CURRENT_USER\Software\Adobe\Dreamweaver CS5.5
    regedit /l:c:\windows\system.dat /r:c:\windows\user.dat /d HKEY_LOCAL_MACHINE\SOFTWARE\Adobe\Dreamweaver

    SHUTDOWN -r -t 10

  2. #2
    Norphy's Avatar
    Join Date
    Jan 2006
    Location
    Harpenden
    Posts
    2,260
    Thank Post
    51
    Thanked 276 Times in 214 Posts
    Blog Entries
    6
    Rep Power
    113
    Have you tried using the REG DELETE command instead?

    Code:
    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

  3. #3

    sparkeh's Avatar
    Join Date
    May 2007
    Posts
    6,737
    Thank Post
    1,272
    Thanked 1,645 Times in 1,101 Posts
    Blog Entries
    22
    Rep Power
    505
    regedit.exe only accepts a .reg file to make edits to the registry - where did you get that syntax?

    So you could call regedit on an existing .reg file or be a bit smarter and use itself as the reg file so something like this:
    Code:
    REGEDIT4
    
    
    ; @echo OFF
    ; CLS
    ; REGEDIT.EXE /S "%~f0"
    ; EXIT
    
    
    [-HKEY_CURRENT_USER\Software\Adobe\Dreamweaver CS5.5]
    [-HKEY_LOCAL_MACHINE\SOFTWARE\Adobe\Dreamweaver]

  4. #4

    Steve21's Avatar
    Join Date
    Feb 2011
    Location
    Swindon
    Posts
    2,689
    Thank Post
    334
    Thanked 515 Times in 483 Posts
    Rep Power
    179
    Quote Originally Posted by sparkeh View Post
    regedit.exe only accepts a .reg file to make edits to the registry - where did you get that syntax?
    Reg is command-line though. ( C:\Windows\System32\reg.exe NOT C:\Windows\regedit.exe )

    - Edit: As sparkeh said, regedit only works with .reg files now. You can only use /d in 98/ME

    Steve
    Last edited by Steve21; 16th May 2012 at 04:48 PM.

  5. #5

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,720
    Thank Post
    3,248
    Thanked 1,049 Times in 971 Posts
    Rep Power
    364
    Batch files - Use REGEDIT to add, read or delete registry values

    Removing registry entries

    To remove an entire "tree" from the registry using REGEDIT and a .REG file, just add a minus sign before the tree name:

    REGEDIT4[-HKEY_CURRENT_USER\DummyTree]will remove the entire tree "DummyTree".
    To remove an individual item from the registry, place the minus sign after the equal sign:

    REGEDIT4[HKEY_CURRENT_USER\DummyTree]"ValueToBeRemoved"=-will remove the individual value "ValueToBeRemoved" from "DummyTree".
    This is demonstrated in the UniqueID.bat example below, a batch file that forces a new LANDesk agent ID.

    How to remove an individual registry key or value using *.INF files and RUNDLL is explained by Bill James.

  6. #6

    Join Date
    May 2012
    Posts
    290
    Thank Post
    0
    Thanked 1 Time in 1 Post
    Rep Power
    0
    Quote Originally Posted by sparkeh View Post
    regedit.exe only accepts a .reg file to make edits to the registry - where did you get that syntax?

    So you could call regedit on an existing .reg file or be a bit smarter and use itself as the reg file so something like this:
    Code:
    REGEDIT4
    
    
    ; @echo OFF
    ; CLS
    ; REGEDIT.EXE /S "%~f0"
    ; EXIT
    
    
    [-HKEY_CURRENT_USER\Software\Adobe\Dreamweaver CS5.5]
    [-HKEY_LOCAL_MACHINE\SOFTWARE\Adobe\Dreamweaver]
    Do i need the ; ?

  7. #7

    Join Date
    May 2012
    Posts
    290
    Thank Post
    0
    Thanked 1 Time in 1 Post
    Rep Power
    0
    also that did not work, and neither did:
    REGEDIT4[-HKEY_CURRENT_USER\Software\Adobe\Dreamweaver CS5.5]
    REGEDIT4[-HKEY_LOCAL_MACHINE\SOFTWARE\Adobe\Dreamweaver]

  8. #8

    Join Date
    May 2012
    Posts
    290
    Thank Post
    0
    Thanked 1 Time in 1 Post
    Rep Power
    0
    REG DELETE seems to have worked, but not for the directory with a space in it. I tired putting it in quotes but still wont delete.

  9. #9


    Join Date
    Feb 2007
    Location
    51.405546, -0.510212
    Posts
    8,774
    Thank Post
    222
    Thanked 2,632 Times in 1,939 Posts
    Rep Power
    779
    To delete the registry keys via RegEdit you need to copy-and-paste the following code into Notepad, save it as a .reg file (e.g. Adobe.reg) and then run regedit /s Adobe.reg.

    Code:
    Windows Registry Editor Version 5.00
    
    [-HKEY_CURRENT_USER\Software\Adobe\Dreamweaver CS5.5]
    [-HKEY_LOCAL_MACHINE\SOFTWARE\Adobe\Dreamweaver]
    To delete the same registry keys via Reg.exe, you would do this...

    Code:
    reg delete "HKCU\Software\Adobe\Dreamweaver CS5.5" /f
    reg delete HKLM\SOFTWARE\Adobe\Dreamweaver /f
    Which account are you running your batch file under? If it's the SYSTEM account, there isn't any point in trying to delete the HKEY_CURRENT_USER registry key because it won't exist.

    Btw, semi-colons are just comments so can be ignored if you want.
    Last edited by Arthur; 16th May 2012 at 06:39 PM.

  10. Thanks to Arthur from:

    mac_shinobi (16th May 2012)

  11. #10

    Join Date
    May 2012
    Posts
    290
    Thank Post
    0
    Thanked 1 Time in 1 Post
    Rep Power
    0
    There must be something wrong with these images, because I cant get Dreamweaver CS5.5 to show up in the wmic product list

    Every other adobe app shows up. When i run a 3rd party uninstall program, i can locate the UUID of the install, but any attempt to modify / repair / uninstall says "This option is only for install packages". Yet when I got to add/remove programs it can be uninstall that way.

    Frustrating!

  12. #11


    Join Date
    Feb 2007
    Location
    51.405546, -0.510212
    Posts
    8,774
    Thank Post
    222
    Thanked 2,632 Times in 1,939 Posts
    Rep Power
    779
    Quote Originally Posted by agarabaghi View Post
    I can't get Dreamweaver CS 5.5 to show up in the wmic product list
    WMIC will only list applications installed via Windows Installer i.e. MSIs not EXEs.

    Was Dreamweaver installed as part of the Creative Suite?

  13. #12

    sparkeh's Avatar
    Join Date
    May 2007
    Posts
    6,737
    Thank Post
    1,272
    Thanked 1,645 Times in 1,101 Posts
    Blog Entries
    22
    Rep Power
    505
    Quote Originally Posted by Arthur View Post
    Btw, semi-colons are just comments so can be ignored if you want.
    Not entirely true.
    The code I posted above is a kind of reg file/batch file in one. In reg files the ; means a comment, the batch file will ignore the ; and process the commands.
    When you run regedit with that code you need the REGEDIT4 line to make it a valid reg file, however when run as a batch file it will throw an error. The CLS line simply clear the error. And you need the regedit line to actually call regedit so that really can't be ignored

  14. Thanks to sparkeh from:

    Arthur (17th May 2012)

  15. #13


    Join Date
    Feb 2007
    Location
    51.405546, -0.510212
    Posts
    8,774
    Thank Post
    222
    Thanked 2,632 Times in 1,939 Posts
    Rep Power
    779
    That's a neat trick.

  16. #14

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,720
    Thank Post
    3,248
    Thanked 1,049 Times in 971 Posts
    Rep Power
    364
    Quote Originally Posted by sparkeh View Post
    Not entirely true.
    The code I posted above is a kind of reg file/batch file in one. In reg files the ; means a comment, the batch file will ignore the ; and process the commands.
    When you run regedit with that code you need the REGEDIT4 line to make it a valid reg file, however when run as a batch file it will throw an error. The CLS line simply clear the error. And you need the regedit line to actually call regedit so that really can't be ignored
    Not being brilliant with batch files, how does the last bit of this line point to itself or know where itself is ??


    ; REGEDIT.EXE /S "%~f0"

  17. #15


    Join Date
    Feb 2007
    Location
    51.405546, -0.510212
    Posts
    8,774
    Thank Post
    222
    Thanked 2,632 Times in 1,939 Posts
    Rep Power
    779
    The %~f0 on the end expands to the fully qualified path of the .cmd/.bat file so you don't have to hard-code it in your batch file. There are lots more you can use too...

    Code:
    %~0         - expands %I removing any surrounding quotes (")
    %~f0        - expands %I to a fully qualified path name
    %~d0        - expands %I to a drive letter only
    %~p0        - expands %I to a path only
    %~n0        - expands %I to a file name only
    %~x0        - expands %I to a file extension only
    %~s0        - expanded path contains short names only
    %~a0        - expands %I to file attributes of file
    %~t0        - expands %I to date/time of file
    %~z0        - expands %I to size of file
    
    The modifiers can be combined to get compound results:
    %~dp0       - expands %I to a drive letter and path only
    %~nx0       - expands %I to a file name and extension only
    %~fs0       - expands %I to a full path name with short names only

SHARE:
+ Post New Thread

Similar Threads

  1. Delete registry key with wildcard
    By glennda in forum Windows 7
    Replies: 15
    Last Post: 5th February 2013, 03:57 PM
  2. Need help with batch files please!
    By richrad_mills in forum Windows
    Replies: 13
    Last Post: 23rd June 2010, 07:24 PM
  3. VB Delete registry keys with sub keys
    By cookie_monster in forum Scripts
    Replies: 1
    Last Post: 6th November 2009, 08:57 AM
  4. run a batch file on logon with a CC3 Network
    By new-2-this in forum How do you do....it?
    Replies: 5
    Last Post: 17th July 2008, 07:57 PM
  5. Batch file to remove registry key doesnt work
    By sidewinder in forum Windows
    Replies: 4
    Last Post: 7th December 2007, 04:48 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •