1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Writing a batch file!

Discussion in 'Windows XP' started by tehon3299, Oct 2, 2003.

Thread Status:
Not open for further replies.
Advertisement
  1. tehon3299

    tehon3299 Thread Starter

    Joined:
    Mar 30, 2003
    Messages:
    209
    I am writing a batch file to remove some registry entries. How would I access the registry via DOS?
     
  2. putasolution

    putasolution

    Joined:
    Mar 20, 2003
    Messages:
    4,823
    you would be better using a reg file rather than a batch file
     
  3. Wirelessguy

    Wirelessguy

    Joined:
    Oct 2, 2003
    Messages:
    19
    the reg file would be the way to go.
     
  4. tehon3299

    tehon3299 Thread Starter

    Joined:
    Mar 30, 2003
    Messages:
    209
    can i call a reg file from a batch file then? what exactly is a reg file??
     
  5. JohnWill

    JohnWill Retired Moderator

    Joined:
    Oct 19, 2002
    Messages:
    106,418
    A plain .REG file can't remove entries as I recall. I use a nifty script generator called Auto-It that's free, and it has the capability to add and delete registry entries. It can also read them and make decisions based on the contents. It's handy for all sorts of automation tasks, way beyond this, it can simulate mouse clicks, etc. :)
     
  6. tehon3299

    tehon3299 Thread Starter

    Joined:
    Mar 30, 2003
    Messages:
    209
    how do i use this? i downloaded it and installed it.
     
  7. putasolution

    putasolution

    Joined:
    Mar 20, 2003
    Messages:
    4,823
    I found this basic script

    Save in red to Notepad as regdelete.vbs

    'RegDelete.vbs
    'Deletes keys or values from the registry.
    '
    'Serenity Macros http://www.angelfire.com/biz/serenitymacros
    'David Candy [email protected]
    '
    On Error Resume Next
    vbPara=vbCRLF & vbCRLF
    strExplain="RegDelete deletes keys and values from the registry." & vbPara & "Keys must end with a backspace and values must not." & vbPara & "Start without parameters to type in a key or value to delete, or place the key or value on the command line (use inverted commas to surround the key or value if it contains spaces)." & vbPara & "Continue"
    strTitle="Reg Delete"
    Key=""
    Dim silent
    Silent=""

    Dim Sh
    Set Sh = WScript.CreateObject("WScript.Shell")
    ReportErrors "Creating Shell"

    Key=GetKey()
    If Key<>"" then
    B=Sh.RegRead (Key)
    If Err.Number=0 Then
    Sh.RegDelete Key
    If Err.Number =0 Then
    If silent<>"yes" Then MsgBox Key & " deleted", vbOKOnly + vbInformation, strTitle
    Else
    ReportErrors "DeletingKey"
    End If
    Else
    If Err.Number=-2147024893 then
    Err.Clear
    MsgBox Key & " didn't exist", vbOKOnly + vbCritical, strTitle
    Else
    ReportErrors "Reading before Deleting Key"
    End If
    End If
    End If

    ReportErrors "Main"
    VisitSerenity

    Function GetKey()
    Dim Ag
    Set Ag=Wscript.Arguments
    ReportErrors "Creating Aguments"
    If Ag.Count=1 then GetKey=Ag(0)
    Silent="yes"
    If Ag.Count >1 then sgBox "Too many parameters on command line. Try enclosing the key in a space",vbOKOnly + vbCritical, strTitle

    If Ag.Count=0 then
    If MsgBox (strExplain, vbYesNo + vbInformation, strTitle)=6 Then
    GetKey=InputBox ("Enter the value or key to delete." & vbPara & "Keys must end in a backspace.", strTitle, strNamet1)
    End If
    End If
    End Function

    Sub ReportErrors(strModuleName)
    If err.number<>0 then Msgbox "Error occured in " & strModuleName & " module of " & err.number& " - " & err.description & " type" , vbCritical + vbOKOnly, "Something unexpected"
    Err.clear
    End Sub

    Sub VisitSerenity
    Dim Ag
    Set Ag=Wscript.Arguments
    If Ag.Count<>1 then
    If MsgBox("This program came from the Serenity Macros Web Site" & vbCRLF & vbCRLF & "Would you like to visit Serenity's Web Site now?", vbQuestion + vbYesNo + vbDefaultButton2, "Visit Serenity Macros") =6 Then
    sh.Run "http:\\www.angelfire.com\biz\serenitymacros"
    End If
    End If
    End Sub




    Double click on it to run
     
  8. tehon3299

    tehon3299 Thread Starter

    Joined:
    Mar 30, 2003
    Messages:
    209
    I need to edit the path in my registry
     
  9. tehon3299

    tehon3299 Thread Starter

    Joined:
    Mar 30, 2003
    Messages:
    209
    OK...I am doing this in a batch file...Anyone know why it will not add the value I am trying to add?

    Windows Registry Editor Version 5.00

    [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters]

    "DataBasePath"=-

    [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters]

    "DataBasePath"="%SystemRoot%\System32\drivers\etc"
     
  10. tehon3299

    tehon3299 Thread Starter

    Joined:
    Mar 30, 2003
    Messages:
    209
    OK..i'm trying this now:

    Windows Registry Editor Version 5.00

    [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters]

    "DataBasePath"="1"

    [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters]

    "DataBasePath"="%SystemRoot%"

    It will put $SystemRoot% but if i try %SystemRoot%\System32 then it just doesn't do anything and leave it as set to 1. What is the deal??
     
  11. JohnWill

    JohnWill Retired Moderator

    Joined:
    Oct 19, 2002
    Messages:
    106,418
    Open the help file, there's a pretty complete description of it's usage, and it's beyond what I'm willing to type in a message! :D
     
  12. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/169100

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice