check to see if a reg key exists
langage: vbscript
I want to check if a registry key exisits, not what its values is, just that fact that its there. what I am trying to do is rebrand office defualt file save locations.
i want to reset that in my vbs logons scripts. so, how can i check if the key exisits?
reason: the key only exisst if word,excel have been run.
-nex6
Re: check to see if a reg key exists
If you go here :
http://ourworld.compuserve.com/homep...azaar/WSH2.htm
about half way down the page there is an example ( You can modify it for your needs to check the existance of a registry key )
Re: check to see if a reg key exists
here is an edited version for you.
No need to set it to a variable ..
if it gives an error when reading the key then it doesnt exist.
Code:
Option Explicit
If KeyExists("HKCR\.bmp\") Then
MsgBox "Found"
Else
MsgBox "Not Found"
End If
Function KeyExists(key)
Dim objShell
On Error Resume Next
Set objShell = CreateObject("WScript.Shell")
objShell.RegRead (key)
Set objShell = Nothing
If Err = 0 Then KeyExists = True
End Function