Page 1 of 1 1
Topic Options
#65013 - 2002-04-30 12:29 AM WriteValue for existing entries?
Rix Offline
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
#65014 - 2002-04-29 02:40 PM Re: WriteValue for existing entries?
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Did you read the manual? Are you sure it's a value you want to check for? If it is, can you not ReadValue or EnumValue?

Post a snippet of the reg.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#65015 - 2002-04-29 03:31 PM Re: WriteValue for existing entries?
Rix Offline
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 Offline
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
#65017 - 2002-04-29 04:05 PM Re: WriteValue for existing entries?
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
I like Brian's TypeValue() solution... tested it... works.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#65018 - 2002-04-29 04:37 PM Re: WriteValue for existing entries?
Rix Offline
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
#65019 - 2002-04-29 04:45 PM Re: WriteValue for existing entries?
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
BTW Rix, Welcome to the board. Don't sweat it, my brain was a tad slow on the uptake as well. What the hay, Monday morning... second cup of coffee... dog ate my homework...
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#65020 - 2002-04-29 05:17 PM Re: WriteValue for existing entries?
BrianTX Offline
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
#65021 - 2002-04-29 05:18 PM Re: WriteValue for existing entries?
Dean R Offline
Starting to like KiXtart

Registered: 2002-03-15
Posts: 115
Loc: Ireland, but Im an Aussie
Its all a big race here Rix [Smile]

I dont try and race these guys anymore, for two reasons

1) I never win
2) I always get it wrong

So now I just watch,
and occasionally throw in the odd smart comment to keep my post number going [Big Grin]
_________________________
-------------------------------- When you can take this stone from my hand Gwasshoppa you are read... *yoink* Gwasshoppa? Gwasshoppa? Where did you go? ---------------------------------

Top
#65022 - 2002-04-29 05:38 PM Re: WriteValue for existing entries?
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Dean,
Just ask lots of questions. You come out on top, as caring, as real educated... can't go wrong with questions... and your post count goes way up... by asking even more questions. [Big Grin]

hmmm.. giving myself away...
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#65023 - 2002-04-29 05:50 PM Re: WriteValue for existing entries?
BrianTX Offline
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 Offline
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
#65025 - 2002-04-29 06:03 PM Re: WriteValue for existing entries?
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Rix,
It's the @error that will tell you if it exists, not the value returned by the function.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#65026 - 2002-04-29 06:05 PM Re: WriteValue for existing entries?
BrianTX Offline
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 Offline
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
#65028 - 2002-04-29 07:05 PM Re: WriteValue for existing entries?
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
I'm not familiar with REG_NONE either, but it if is a valid type then only @error would show it to not exist or some other impediment like rights, etc.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 708 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.05 seconds in which 0.017 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org