Page 1 of 1 1
Topic Options
#115355 - 2004-03-02 10:02 PM Read Registry Key and Set Value
Bob Deerinwater Offline
Starting to like KiXtart

Registered: 2002-05-05
Posts: 101
Loc: Covina California
Hello,
Here is what i am trying to accomplish. I have a need to read a registry key and set the value to "PPII". The key may only have one entry or it may have ten depending on how many printers are installed. Just need a push in the right direction....
The registry looks like this:
[HKEY_CURRENT_USER\Software\Meditech\Wrkstn\INIPTPDRIVER]
"HP LaserJet Series II"="HPLASERII"
"HP LaserJet 4/4M"="HPLASERIIII"
"HP LaserJet 4M Plus"="HPLASERIIII"
"HP LaserJet 4M"="HPLASERIIII"
"HP LaserJet 4"="HPLASERIIII"
"\\\\ICC_ADMIN\\I31301"="PPII"

Top
#115356 - 2004-03-02 10:19 PM Re: Read Registry Key and Set Value
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
See the KiXtart Manual under ADDKEY(), DELKEY(), READVALUE(), WRITEVALUE() andf the following post: RegRename()

If that doesn't help, you'll need to explain in more detail what "value" you want to change.
_________________________
There are two types of vessels, submarines and targets.

Top
#115357 - 2004-03-02 10:27 PM Re: Read Registry Key and Set Value
MDavis Offline
Fresh Scripter

Registered: 2004-01-05
Posts: 40
Loc: New Orleans, LA
Okay, I'm no expert, but this is what I would try

Code:

dim $val1, $r, $reg, $key

$reg = "HKEY_CURRENT_USER\Software\Meditech\Wrkstn\INIPTPDRIVER"
$key = "\\\\ICC_ADMIN\\I31301"

If KeyExist($reg)
$val1 = ReadValue($reg, $key)
If NOT $val1 = "PPII"
$r = WriteValue($reg, $key, "PPII","REG_SZ")
Else
EndIf



I think that should work?
_________________________
Micah Davis "A truly wise man never plays leapfrog with a unicorn."

Top
#115358 - 2004-03-02 10:33 PM Re: Read Registry Key and Set Value
Bob Deerinwater Offline
Starting to like KiXtart

Registered: 2002-05-05
Posts: 101
Loc: Covina California
The value that i want to change is the "HPLaser**" the need to be changed to PPII. I will start looking at the suggestions. Thank You
Top
#115359 - 2004-03-02 10:48 PM Re: Read Registry Key and Set Value
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
So you want to check all registry value for the correct data?
Code:

$key='HKEY_CURRENT_USER\Software\Meditech\Wrkstn\INIPTPDRIVER'
$values=arrayenumvalue($key) ;UDF
for each $value in $values
$data=readvalue($key,$value)
if left($data,7)='HPLaser'
$rc=writevalue($key,$value,'PPII','REG_SZ')
endif
next

_________________________
There are two types of vessels, submarines and targets.

Top
#115360 - 2004-03-03 03:15 AM Re: Read Registry Key and Set Value
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Quote:

I'm no expert



Try to get your terminology straight.
"\\\\ICC_ADMIN\\I31301" is not a Key but a Value!
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#115361 - 2004-03-03 03:24 PM Re: Read Registry Key and Set Value
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Proper terminology is explained in the FAQ Forum under Registry
_________________________
There are two types of vessels, submarines and targets.

Top
#115362 - 2004-03-03 04:43 PM Re: Read Registry Key and Set Value
Bob Deerinwater Offline
Starting to like KiXtart

Registered: 2002-05-05
Posts: 101
Loc: Covina California
Thanks for the help on this. After further investigation i found that changing the HPLASER value would not help. It appear that the program read the default printer and the adds it to the INIPTPDRIVER registry key (hope my terminology is correct) and then sets the value to "" so i have changed the script to replace the "" with "PPII" here is the code. i added the call to the udf is that needed?
Code:

Call w:\arrayenumvalue.udf
$Print='HKEY_CURRENT_USER\Software\Meditech\Wrkstn\INIPTPDRIVER'
$values=arrayenumvalue($Print)
For Each $value In $values
$data=ReadValue($Print,$value)
If Left($data,1)=''
$rc=WriteValue($Print,$value,'PPII','REG_SZ')
EndIf
Next


Thank again. This place is awesome!!!!!

Top
#115363 - 2004-03-03 04:56 PM Re: Read Registry Key and Set Value
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
See the FAQ Forum under How to use UDFs
_________________________
There are two types of vessels, submarines and targets.

Top
#115364 - 2004-03-03 05:56 PM Re: Read Registry Key and Set Value
MDavis Offline
Fresh Scripter

Registered: 2004-01-05
Posts: 40
Loc: New Orleans, LA
Yeah, I was typing it quick. Sorry for the mixup. Value not key, got it.
_________________________
Micah Davis "A truly wise man never plays leapfrog with a unicorn."

Top
Page 1 of 1 1


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

Who's Online
0 registered and 484 anonymous users online.
Newest Members
Sir_Barrington, batdk82, StuTheCoder, M_Moore, BeeEm
17886 Registered Users

Generated in 0.223 seconds in which 0.193 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