Page 1 of 1 1
Topic Options
#74909 - 2003-05-08 01:41 PM writevalue in HKCU during logon on W2K Prof.
elguek Offline
Lurker

Registered: 2003-02-21
Posts: 4
Hi,

i´ve a Problem to edit some Values in HKCU during the Logon on W2K Clients.
I want to change (as sample) the Value for the Word XP Template Path.
When i run the Scipt after the logon, it works. But nothing happens during the logon.
Who can help or have ideas ?

[Confused] elguek

Top
#74910 - 2003-05-08 01:45 PM Re: writevalue in HKCU during logon on W2K Prof.
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
please, could you post your code part.

makes me wonder what could be the values that might be locked during logon...
_________________________
!

download KiXnet

Top
#74911 - 2003-05-08 02:10 PM Re: writevalue in HKCU during logon on W2K Prof.
elguek Offline
Lurker

Registered: 2003-02-21
Posts: 4
Hi,
here is my Code:

;Word Dokumentenordner
if exist ("C:\wa32\office\Office10\winword.exe")
$Subkey="HKEY_CURRENT_USER\Software\Microsoft\Office\10.0\Word\Options"
$entry="DOC-PATH"
$datatype="REG_EXPAND_SZ"
$expression="O:\"
$errmsg="Word XP Document Folder could not set"

gosub CheckKey
endif

return

:CheckKey
$RCCheck = Keyexist("$Subkey")
if $RCCheck = 1
gosub WriteKey
else
? "Subkey does not exist, i create it" ?
$RC = addkey ("$Subkey")
if $RC = 0
? "Subkey created"
gosub Writekey
else
? "Error during the cration of the Subkey" + $Subkey +" "+ @Error + " " + @SError
$RC = LogEvent(1,1,"Error during the cration of the Subkey " + $Subkey +" "+ @Error + " " + @SError ,"","OffXPInit/CheckKey" )
endif
endif
return

:WriteKey
$RC = WriteValue("$Subkey","$entry","$expression","$datatype")
If @Error > 0
$RC = LogEvent(1,1,"$errmsg : "+@Error+ " " +@SError ,"","OffXPInit/WriteKey" )
Color r+/n
?
"Err: " + $errmsg +" " + @SError
?
Color w+/b
?
endif
$Subkey=0
$entry=0
$expression=0
$datatype=0
$errmsg=0

return

===============

Top
#74912 - 2003-05-08 02:19 PM Re: writevalue in HKCU during logon on W2K Prof.
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
I assume you have old kix version?

please reply asap as that affects my real answer
_________________________
!

download KiXnet

Top
#74913 - 2003-05-08 02:25 PM Re: writevalue in HKCU during logon on W2K Prof.
elguek Offline
Lurker

Registered: 2003-02-21
Posts: 4
My Version of KIX is 4.02.
Top
#74914 - 2003-05-08 02:35 PM Re: writevalue in HKCU during logon on W2K Prof.
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
4.02, so this should do:

;Word Dokumentenordner
if keyexist ("HKLM\Software\Microsoft\Office\10.0") ;office XP installed
$subkey="HKCU\Software\Microsoft\Office\10.0\Word\Options"
$entry="DOC-PATH"
$datatype="REG_EXPAND_SZ"
$expression="O:\"
$errmsg="Word XP Document Folder could not set : "

if not keyexist($subkey)
$RC = addkey($subkey)
if @error
$RC = LogEvent(1,1,$errmsg + @Error + " " + @SError,"","OffXPInit/WriteKey")
endif
endif
$RC = WriteValue($Subkey,$entry,$expression,$datatype)
If @Error
$RC = LogEvent(1,1,$errmsg + @Error + " " + @SError,"","OffXPInit/WriteValue")
endif
endif ;end of officeXP init

might not be perfect but does not have that fuzzy gosub thingie anymore...
it was hard to follow.
what is the error reported with this script if not work?

btw, the script is copy-pasteable to any editor directly.

[ 08. May 2003, 14:38: Message edited by: Lonkero ]
_________________________
!

download KiXnet

Top
#74915 - 2003-05-09 09:47 AM Re: writevalue in HKCU during logon on W2K Prof.
elguek Offline
Lurker

Registered: 2003-02-21
Posts: 4
Now it works.
Thank you for your Script.
It was a mistake of me.
One If statment in the main Script wasn´t closed [Roll Eyes]
Sorry!
I think i have to learn debugging. :-(

Top
#74916 - 2003-05-10 12:15 AM Re: writevalue in HKCU during logon on W2K Prof.
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
yeah...
btw, have you started testing already with 4.12 or 4.21 RC?

there is already pretty much changed since 4.02

I see that your syntax is kinda 3.xx still but with some playing around with the new stuff alone and with the help of the board think you will could kick onto the next level!

anyway, good that it works.

cheers.
_________________________
!

download KiXnet

Top
#74917 - 2003-05-09 08:46 PM Re: writevalue in HKCU during logon on W2K Prof.
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
Loc: CA
Lonkero,

Just to nit pick - [Wink]

If after your first error that you could not add the key, you then go on to try and write to that key. Yes, I know it is fast and won't cause a problem, but better coding would no longer attempt to go further as the key can not be created, thus it can not be written to.

Top
#74918 - 2003-05-10 02:24 AM Re: writevalue in HKCU during logon on W2K Prof.
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
you are right...

although, it just needs a push up with additional else's or one if check...
like:

if keyexist($subkey)
$RC = WriteValue($Subkey,$entry,$expression,$datatype)
endif


but...
it works with current way too.
it just will produce 2 log-events instead of 1.
_________________________
!

download KiXnet

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
1 registered (Allen) and 382 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.076 seconds in which 0.025 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