Page 1 of 1 1
Topic Options
#211929 - 2016-09-01 09:52 PM WRITEVALUE function fails but REG ADD works
JNK Offline
Fresh Scripter

Registered: 2006-04-11
Posts: 33
Loc: USA
I have a weird issue. First, some environment information:

Windows 10 Enterprise, 64-bit; fully patched and updated (current branch)
Kixtart (wkix32) 4.66
Domain joined
Logged on as a Domain User; User is a Local Admin
User Account Control (UAC) is turned off (never notify)

I have a custom registry setting I need to update: HKLM\software\firm\variables | test="1" (reg_sz) during the running of the Logon Script.

My logon script code looks like this: $_ = writevalue("HKLM\software\firm\variables","test","1","reg_sz")
The result (@error) is 5 (access denied) and the entry is not written (obviously).

BUT if I run a REG ADD "HKLM\software\firm\variables" /v "test" /d "1" /t "reg_sz" /f

in a cmd window, the result is 0 (success) and the entry is written.

The command is successful on both an "elevated" and a "non-elevated" cmd.exe.

I also have a Group Policy in place to modify the ACL of HKLM\software\firm to "Administrators: Full Control". These permission are propagated down to all sub keys and values. Registry hive permissions have been verified in the GUI.

Is there a bug in the WRITEVALUE function in 4.66 or am I missing something?

Top
#211931 - 2016-09-01 10:38 PM Re: WRITEVALUE function fails but REG ADD works [Re: JNK]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4549
Loc: USA
Put this at the top of your script.
$RC=setoption("WOW64AlternateRegView","On")

Short story, kix32 is a 32bit process and by default writes to HKLM\Software\wow324node. If you look there, you will see the value you are writing, because of redirection. Changing the option above gives you control over the normal software key.

Top
#211932 - 2016-09-02 01:11 AM Re: WRITEVALUE function fails but REG ADD works [Re: Allen]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
Allen - that would not explain the Error 5 being returned. The part about the WOW3264 is spot-on.

I can replicate this here shortly - I'm NOT an admin normally but can log in or start a command prompt as one.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#211933 - 2016-09-02 01:20 AM Re: WRITEVALUE function fails but REG ADD works [Re: Glenn Barnas]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4549
Loc: USA
I didn't read it closely enough... missed the Error 5 part.
Top
#211936 - 2016-09-02 01:25 PM Re: WRITEVALUE function fails but REG ADD works [Re: Allen]
JNK Offline
Fresh Scripter

Registered: 2006-04-11
Posts: 33
Loc: USA
ah, missing environment detail. I think I already have the WOW64AlternateRegView option set to ON but let me verify that. If it turns out to be that simple, I hang my head in shame for making such a rookie mistake.

... always appreciate the helpful folks here in the forum. I lurk here quite frequently and have learned a lot!

Thanks!

Top
#211937 - 2016-09-02 01:40 PM Re: WRITEVALUE function fails but REG ADD works [Re: JNK]
JNK Offline
Fresh Scripter

Registered: 2006-04-11
Posts: 33
Loc: USA
UPDATE: Confirmed I had code in place to set the WOW64AlternateRegView option.

Unfortunately, I also found a typo.

#grumble

Thank you for pointing me in the right direction!


Edited by JNK (2016-09-02 01:41 PM)

Top
#211938 - 2016-09-02 01:57 PM Re: WRITEVALUE function fails but REG ADD works [Re: JNK]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
tired of loosing time with typos in script?
Don't let yourself down by using notepad .. there are bazillions of good and reliable editors with editable syntax highlighting.

In the lounge forum there is an extenisve thread about these. There are even free of charge ones which work a treat when getting used to ;\)
_________________________



Top
#211941 - 2016-09-04 01:44 PM Re: WRITEVALUE function fails but REG ADD works [Re: Jochen]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
Yeah - including the Sanity function - which is built in to KGen.

KGen is part of the Kix Development package and allows you to write scripts without manually specifying functions, and it lets you break large scripts into smaller files. Run KGEN against your primary script source file and it will combine all of the sub-files, then scan them for any needed UDFs, adding them to the finished script. It does this recursively so even UDFs with dependencies are resolved.

When KGen finishes assembling the script, it runs Sanity, which scans the full script looking for unbalanced functions, quotes, parens, checks for undeclared or duplicately defined variables, and variables or macros in strings. It even generates a variable list reporting when it was declared and first defined. A "Code Map" helps to quickly find unbalanced statements. KGen supports directives to load specific "Private" UDFs, prevent scanning for dependencies, define additional libraries, and even skip parsing of a line that's correct but always generates a warning (Execute commands often have $ in the strings).

The Kix Development pack is a free download from my site, is written in Kix and includes our entire production UDF library.

I write a large number of complex Kix scripts that we use in production, and I use KGen for every one of them. Running KGen without args will locate the BUILD.INI file, where I've configured the defaults to not tokenized the code and to run sanity. I then have 3 other sections called DEV, PKG, and PROD. These all simply build the script, tokenize the result (leaving an un-tokenized .GEN file), bypass Sanity, and then copy the resulting script to the Dev environment, a Package folder for deployment, or our Production environment.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

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 370 anonymous users online.
Newest Members
Timothy, Jojo67, MaikSimon, kvn317, kixtarts2025
17874 Registered Users

Generated in 0.15 seconds in which 0.114 seconds were spent on a total of 13 queries. Zlib compression enabled.

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