#65013 - 2002-04-30 12:29 AM
WriteValue for existing entries?
|
Rix
Lurker
Registered: 2002-04-29
Posts: 4
|
Hi all,
I am trying to import registry entries from many servers into one new server. I can successfully get the scripts to export\import, but we have thousands of users - duplication of share names is inevitable.
Is there a way to test for the existance of an entry before overwriting?
I basically need the equivalent of an "ExistValue" command. Anyone got any pointers for me?
TIA,
Rix
|
|
Top
|
|
|
|
#65015 - 2002-04-29 03:31 PM
Re: WriteValue for existing entries?
|
Rix
Lurker
Registered: 2002-04-29
Posts: 4
|
Thanks for the fast response.
The problem with EnumValue is that it's params require an index, rather than the value name.
I am exporting the registry contents from one server to a text file, then creating registry entries to the new server by parsing through the created file. Because of this, I am attempting to read each entry via ReadValue:
$x=readvalue["$currentKey","$currentValueName"] if $x <> 0 messagebox ["Create Entry", "Testing", 0] else messagebox ["Existed, ignore.", "Testing", 0] endif
However, the error codes state that the full ASCII representation is returned if the value exists, an error if otherwise. This sounds fine, but then I would need to code something like this:
$x=readvalue["$currentKey","$currentValueName"] if $x < 6118 messagebox ["Go For It", "Testing", 0] endif
But this still brings in some invalid entries. Does this make sense?
Cheers,
Rix
|
|
Top
|
|
|
|
#65016 - 2002-04-29 03:52 PM
Re: WriteValue for existing entries?
|
BrianTX
Korg Regular
Registered: 2002-04-01
Posts: 895
|
What are you trying to do? Why do you need to import registry entries?
If you want to test for registry values before overwriting, you should be able to with:
code:
$regread = readvalue ("Regkey","RegValue") If $regread <> "" ? "Copying stuff to registry" Else ? "Skipping and going to the next value" Endif
Another possibility is you do something like this:
code:
$Typevalue = ReadType("Regkey","RegValue") If @ERROR = 0 ? "Value Exists" Else ? "Value Doesn't exist" Endif
(This last method is untested.. feel free to test.)
Brian
|
|
Top
|
|
|
|
#65018 - 2002-04-29 04:37 PM
Re: WriteValue for existing entries?
|
Rix
Lurker
Registered: 2002-04-29
Posts: 4
|
Hey guys, thanks. I tried the second method and it works great! Mr.Brain isn't functioning too well today, took me a while to grasp the plot.
This was my first post to this forum, and I am unbelievable impressed with the support.
Thanks again,
Richard.
PS. BrianTX for your curiosity, I am attempting to amalgamate several servers into one File & Print server - copying across all of the shares from each old server. I have it fully cracked now, this was the last piece in the puzzle.
|
|
Top
|
|
|
|
#65020 - 2002-04-29 05:17 PM
Re: WriteValue for existing entries?
|
BrianTX
Korg Regular
Registered: 2002-04-01
Posts: 895
|
Rix!
That's a cool thing.. I would love to hear how you have done that. That's certainly worthy of further discussion.
Do you have a list of steps you went through and perhaps scripts that accomplish this for you? Someday we might want to consolidate our own print servers (and upgrade them to Windows 2000)
Brian
|
|
Top
|
|
|
|
#65023 - 2002-04-29 05:50 PM
Re: WriteValue for existing entries?
|
BrianTX
Korg Regular
Registered: 2002-04-01
Posts: 895
|
No worries, Dean. I just make a fool of myself. Hopefully someone can glean some good information somewhere, even if I:
1. Am too slow. 2. Don't do it the "right" way. 3. Make a gazillion typos. 4. Overlook the obvious.
Ya know.. every once in awhile you're bound to stumble on something someone can use. Sometimes the "right" method isn't always workable in a given environment (err. managament?). I always like it when people post their opinions, even if it's not a complete solution, because sometimes the smallest spark lights the bonfire.
Brian
|
|
Top
|
|
|
|
#65024 - 2002-04-29 05:54 PM
Re: WriteValue for existing entries?
|
Rix
Lurker
Registered: 2002-04-29
Posts: 4
|
Guys, I had to modify the contents of $x, since if the entry didn't exist the value of readtype becomes "REG_NONE" and NOT "0".
$x=readtype("$currentKey","$currentValueName") if $x = "REG_NONE" $x=writevalue... create new value else $x=writeline... existed, error log endif
As for the code, how do we add attachments? Be aware, my code is VERY verbose, I'm no expert!
My basic strategy was:
1. Output registry contents from HKLM\system\currentcontrolset\services\lanmanserver\shares from each server to a text file.
2. Parse through text file, checking existance of keys/entries and adding where necessary.
I haven't actually tested it on a server yet, but it works fine on registry entries from my own PC that I sacrificed. Maybe this isn't exactly what you expected, it's nothing overly complicated.
Chortle, I agree Dean R. I'll also be "He who lurks in the background".
Right, I'm off for my mates birthday bash. Later...
Rix
|
|
Top
|
|
|
|
#65026 - 2002-04-29 06:05 PM
Re: WriteValue for existing entries?
|
BrianTX
Korg Regular
Registered: 2002-04-01
Posts: 895
|
One thing that worries me on this is the files. It's one thing to change all the registry values and have the printers appear in the printers folder, but will it actually print? Are you copying all the print files?
Brian
|
|
Top
|
|
|
|
#65027 - 2002-04-29 06:09 PM
Re: WriteValue for existing entries?
|
BrianTX
Korg Regular
Registered: 2002-04-01
Posts: 895
|
Les, I was thinking about commenting on it being the @ERROR, but I really don't know. I've never heard of a "REG_NONE" key, so it sounds to me like this is KIXtart's way of telling you the value doesn't exist. Is this documented anywhere? The READTYPE function says "REG_NONE" is a possible date type returned, but it doesn't specify that this is returned if there is no value.
Brian
|
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 1013 anonymous users online.
|
|
|