RegWrite() -registry key write.
RegRead() - registry key read.
RegDelete() - registry key delete.
My JScript Source code..
var WSHShell = WScript.CreateObject("WScript.Shell");
var Reg_Key =
"HKLM\\SYSTEM\\CurrentControlSet\\services\\InetInfo\\Parameters\\DisableMem
oryCache";
if( Reg_Key ) {
WSHShell.Echo("DisableMemoryCache registry key
EXISTENCE!");
}
else {
WSHShell.RegWrite(Reg_Key,0x00000000,"REG_DWORD");
}
please Query the registry key existing?
RegQuery?
Here are three functions for you (in VBScript, but they should be easy to port I
think):
RegKeyExists, RegValueExists, RegRead
<documentation>
RegKeyExists(sRegKey)
Input param:
sRegKey ' With or without trailing \,
abbreviasjon like eg. HKLM is allowed.
Return value:
Is True if registry key exists, else False.
Example on use:
bRetVal = RegKeyExists("HKCU\Software\Bogus")
RegValueExists(sRegValue)
Input param:
sRegValue ' NB! Value, not Value Data. Abbreviasjon
like eg. HKLM is allowed.
Return value:
Is True if registry value exists, else False.
Note: If sRegValue has a trailing \, True will be returned if
Defalt value (="@" in a registry file) is set (but its
value data can still be empty!), else False will be
returned (seen as "(value not set)" with Regedit.exe)
Example on use:
bRetVal = RegValueExists("HKCU\Software\Bogus\Some value")
RegRead(sRegValue)
Input param:
sRegValue ' Abbreviasjon like eg. HKLM is allowed.
Return value:
Value data, will be "" if non existing key or value
Note: If sRegValue has a trailing \, value data for Defalt value
(="@" in a registry file) will be returned
Example on use:
vRetVal = RegRead("HKCU\Software\Bogus\Some value")
vRetVal = RegRead("HKCU\Software\Bogus\") ' Returning value data
for Defalt value.
</documentation>
--------------------------------------------------------------------------------------
<code>
Set oShell = CreateObject("WScript.Shell")
Set oFSO = CreateObject("Scripting.FileSystemObject")
Function RegKeyExists(sRegKey)
Dim RegReadReturn
RegKeyExists = True
sRegKey = Trim (sRegKey)
If Not Right(sRegKey, 1) = "\" Then
sRegKey = sRegKey & "\"
End if
On Error Resume Next
RegReadReturn = oShell.RegRead(sRegKey)
If Err Then
If LCase(Left(err.description,7)) = "invalid" Then
'key not found...
RegKeyExists = False
End if
Err.clear
End if
On Error Goto 0
End Function
Function RegValueExists(sRegValue)
Dim RegReadReturn
RegValueExists = True
On Error Resume Next
RegReadReturn = oShell.RegRead(sRegValue)
If Err Then
RegValueExists = False
Err.clear
End if
On Error Goto 0
End Function
Function RegRead(sRegValue)
On Error Resume Next
RegRead = oShell.RegRead(sRegValue)
' If the value does not exist, error is raised
If Err Then
RegRead = ""
Err.clear
End if
On Error Goto 0
' If a value is present but uninitialized the RegRead
' method returns the input value (Way to go MS!).
If RegRead = sRegValue Then
RegRead = ""
End if
End Function
</code>
Regards,
Torgeir