Writing a batch file!

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

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?
 

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??
 

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. :)
 
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
 

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"
 

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??
 

JohnWill

Retired Moderator
Joined
Oct 19, 2002
Messages
106,418
Originally posted by tehon3299:
how do i use this? i downloaded it and installed it.
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
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

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 807,865 other people just like you!

Latest posts

Staff online

Top