#201125 - 2010-12-10 09:15 PM
READVALUE function -- Weird results
|
JNK
Fresh Scripter
Registered: 2006-04-11
Posts: 33
Loc: USA
|
First, my environment:
Kix: 4.61 O/S: Windows 7 Enterprise, 32-bit
While working on a mainteance script, I stumbled upon a weird issue that really has me head-scratching. I am having some weird (read: different) results with the READVALUE function, where I get one value if I direct output to a log file and a different value if I output to the screen.
; ===== Open the log file =====
$log = split (@scriptname,".")
$logfile = @scriptdir + "\" + $log[0] + ".log"
$x = redirectoutput ($logfile,1)
" ========== @scriptname =========="?
; ===== Read value from registry =====
$regkey = "hkcu\software\microsoft\windows\currentversion\internet settings\connections"
$regentry = "defaultconnectionsettings"
$regdata = readvalue ($regkey,$regentry)
$regdata ?
; ===== The bitter end =====
" ========== @scriptname =========="?
$x = redirectoutput ("")
exit 0
If I open the log file (in the same folder as my .kix script), I see a value of ...
4600000022010000090000000e00000032382e38362e36332e33323a3830070000002a2e6c6 f63616c000000000500000000000000a0b9e676a198cb010000000000000000000000000200 000002000000ac10011f0000000000000000000000000000000000000000000000001700000 0000000000000000000000000000000000000000100000000000000001c0000000000000000 000000000000000000000000000000000000000000000017000000000000000000000000000 0000000ffffac10011f00000000000000001700000000000000000000000000000000000000 00000001000000000000000099000099302f0000e0614200d8e741000000000004000000000 00000010000000300000000000000000000000c8d4200feffffff0c00000002000000010042 000000000080000000000000000000000000000000000000000000000000000000
This value is correct and matches the value I see when viewing the registry in Regedit.
Now, if I use the same code and get rid of the log file, the output goes to the screen.
; ===== Read value from registry =====
$regkey = "hkcu\software\microsoft\windows\currentversion\internet settings\connections"
$regentry = "defaultconnectionsettings"
$regdata = readvalue ($regkey,$regentry)
$regdata ?
sleep 20 ; so I have time to copy the text from the window ...
exit 0
Instead of the value I saw before, I get ... 0000000000800000000000000000000000000000000000000000000000000000004200feffffff0c00000002000000010042 instead.
I can duplicate the issue on XP Pro and Windows 7 Enterprise, 64-bit.
Kixtart 4.53, 4.60, 4.61 BETA and 4.61 all yield the same result.
Any ideas?
Edited by Glenn Barnas (2010-12-10 10:07 PM) Edit Reason: broke long line
|
|
Top
|
|
|
|
#201182 - 2010-12-16 05:52 PM
Re: READVALUE function -- Weird results
[Re: Lonkero]
|
JNK
Fresh Scripter
Registered: 2006-04-11
Posts: 33
Loc: USA
|
Sorry for the late reply. I have been out of commission for a couple of days.
Yes, the line was wrapping onto of itself in the command window and adding the $Rc=SetOption('WrapAtEOL', 'On') corrected the issue. I knew it would be something silly -- and now that I see the answer, I am ashamed (but not afraid) to admit I missed it.
Thank you to all of the smart people on this board for pointing me in the right direction.
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
1 registered
(Allen)
and 781 anonymous users online.
|
|
|