Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checking if Registry Key's or Value's exist

Status
Not open for further replies.

benwaynet

IS-IT--Management
Dec 20, 2007
3
US
I'm trying to get the function from

If a registry item exists (key or value, depending on what you pass it).

to work, it allows returns false, even if the key exist

I'm calling the function like thist

WScript.echo RegistryItemExists ("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\")

Thanks,jb
 
Someone was being naughty and did not use Option Explicit when they made their functions. Add this line

Dim WshShell:Set WshShell = CreateObject("WScript.Shell")

to the top of the RegistryItemExists() function.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
In addition, it would appear that you want RegistryKeyExists, rather than RegistryItemExists.
 
That was it thank you.
funny think is, I would assume true would = 1 and false would = 0

But True returns -1 and false returns 0

But as long as its consistent, I can work with it.

thanks,jb
 
RegistryKey would be the values on the right hand side of regedit, and RegistryItem is the 'folders' on the left correct?

I'm just checking if the registry 'folder' exist before I try to edit some registry keys.

jb
 
Other way around. The keys are on the left in Regedit.

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top