Page 1 of 2 12>
Topic Options
#179875 - 2007-08-28 05:32 PM LoadKey problem
luca Offline
Fresh Scripter

Registered: 2003-06-27
Posts: 5
I try to use loadkey to import a registry key.

I have this test script:
writevalue("HKEY_CURRENT_USER\Test","Test","ORIGINAL","REG_SZ")
? "save"
$ReturnCode = SaveKey("HKEY_CURRENT_USER\Test", "c:\zz_test.dat")
? $ReturnCode
If $ReturnCode = 0
? "Key SAVED...."
Endif

writevalue("HKEY_CURRENT_USER\Test","Test","CHANGED","REG_SZ")

? "-----------------"
? "load"
$ReturnCode = LoadKey("HKEY_CURRENT_USER\Test", "c:\zz_test.dat")
? $ReturnCode
If $ReturnCode = 0
? "Key loaded...."
Endif


I run the script and this is the result.

================================
C:\test>KIX32.EXE zz_test.KIX
0
save
0
Key SAVED....0
--------------
load
5
================================


I done a lot of test, but the script dosen't work.
In the "Test" key I found always CHANGED.
Why?
I'm administrator of my pc, it is not a permission problem.


Thank You
Luca Passioni

Top
#179885 - 2007-08-28 06:54 PM Re: LoadKey problem [Re: luca]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
You may THINK permissions aren't a problem, but - the return code "5" is "Access Denied". Odd that WriteValue works, but something is preventing the LoadKey from gaining proper access.

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

Top
#179904 - 2007-08-29 12:27 AM Re: LoadKey problem [Re: Glenn Barnas]
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Borrowing from the manual:
 Quote:
On Windows NT or higher, using LOADKEY requires Backup and Restore privileges.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#180146 - 2007-09-05 12:48 AM Re: LoadKey problem [Re: Les]
luca Offline
Fresh Scripter

Registered: 2003-06-27
Posts: 5
I can writevalue without problem.
I tried on a Win2003 Server and I was the administrator.
FULL CONTROL of the registry key.
I tried on a Vista Business, check registry permission and was FULL CONTROL.

5- is access denied, but this is impossible!

Someone have more suggestions?


Thank You
Luca Passioni

Top
#180147 - 2007-09-05 01:34 AM Re: LoadKey problem [Re: luca]
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Do you have Backup and Restore privileges? I think not.

WriteValue() does not need Backup and Restore privileges.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#180163 - 2007-09-05 05:34 PM Re: LoadKey problem [Re: Les]
luca Offline
Fresh Scripter

Registered: 2003-06-27
Posts: 5
I'm the "ADMINISTRATOR", I think that administrator has "Backup/Restore" permission.
What do You think about?

I open regedt32, open the key and the permission are "FULL CONTROL".
How can I set "Backup/Restore" permission?


Thank You
Luca P.

Top
#180164 - 2007-09-05 05:43 PM Re: LoadKey problem [Re: luca]
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
I guess: put your user id in the local group called "Backup Operators"?
Top
#180174 - 2007-09-05 09:56 PM Re: LoadKey problem [Re: Witto]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
"I think I have supernatural powers, thus I have them"
hmm...

yeah, in some cases, you really need to give yourself some rights.
on the other hand, in some cases you need to remove them to be able to do stuff.
that's what makes administration fun \:\)
_________________________
!

download KiXnet

Top
#180179 - 2007-09-05 11:19 PM Re: LoadKey problem [Re: luca]
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
 Originally Posted By: luca
I'm the "ADMINISTRATOR", I think that administrator has "Backup/Restore" permission.
What do You think about?
I think you don't know what you think you know.

You can type "ADMINISTRATOR" in all caps if you want, you can even "BOLD" it if you like but that doesn't change the fact.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#180180 - 2007-09-06 01:12 AM Re: LoadKey problem [Re: Lonkero]
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
 Originally Posted By: Jooel
"I think I have supernatural powers, thus I have them"
hmm...
cogito ergo sum?
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#180181 - 2007-09-06 02:15 AM Re: LoadKey problem [Re: Les]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
Loc: CA
 Originally Posted By: Les
Borrowing from the manual:
 Quote:
On Windows NT or higher, using LOADKEY requires Backup and Restore privileges.


Borrowing from Microsoft TechNet:
Default User Rights for Groups in Active Directory
Back up files and directories : Administrators, Server Operators, Backup Operators
Restore files and directories : Administrators, Server Operators, Backup Operators

Default User Rights for Local Groups
Back up files and directories : Administrators, Backup Operators
Restore files and directories : Administrators, Backup Operators



Not sure what is causing the access denied as I've not looked at or played with the code, but an Administrator has Backup/Restore rights. However that does not mean that an Administrator has FULL ACCESS everywhere. The SYSTEM account pretty much does but there are locations that the Administrator does not have Full Rights on purpose.

Top
#180182 - 2007-09-06 04:02 AM Re: LoadKey problem [Re: NTDOC]
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
If I understand correctly, he had problems under Vista Business. And as some of us have already suffered through, even the Administrator account under Vista is neutered. So, we will need to explicitly know the operating system used by the account, whether the account is inthe administrators security group, and whether the Backup and Restore privilege are actually enabled for the account.
_________________________
There are two types of vessels, submarines and targets.

Top
#180184 - 2007-09-06 05:46 AM Re: LoadKey problem [Re: Sealeopard]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
Loc: CA
Think he tried Vista after it failed on Server 2003
 Quote:
I tried on a Win2003 Server and I was the administrator.


But it could be his code or a portion of it - just don't have the time to code it and test it for him right now.

Top
#180189 - 2007-09-06 12:08 PM Re: LoadKey problem [Re: NTDOC]
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1894
Loc: Hilversum, The Netherlands
Why not use ReadValue instead ?
Top
#180215 - 2007-09-06 09:50 PM Re: LoadKey problem [Re: Arend_]
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
apronk,
I think you mean WriteValue()

I tested the following:
I am Domain Admin
I put my Domain Account (Domain\UserID) in the local group "Backup Operators" on my computer.
(I also tested this when I was NOT in the "Backup Operators" group)
In the registry, I created a new key "HKEY_CURRENT_USER\test"
Here is the script I tried:
;Script Options
If Not @LOGONMODE
    Break On
Else
    Break Off
EndIf
Dim $RC
$RC = SetOption("Explicit", "On")
$RC = SetOption("NoMacrosInStrings", "On")
$RC = SetOption("NoVarsInStrings", "On")
If @SCRIPTEXE = "KIX32.EXE"
    $RC = SetOption("WrapAtEOL", "On")
EndIf

;Code
$RC
 =
SaveKey("HKEY_CURRENT_USER\test","c:\test.dat")
If @ERROR
    "SaveKey Error" ?
   
"Error " + @ERROR + ": " + @SERROR ?
   
$RC ?
EndIf

$RC = LoadKey("HKEY_CURRENT_USER\test","c:\test.dat")
If @ERROR
    "LoadKey Error" ?
   
"Error " + @ERROR + ": " + @SERROR ?
   
$RC ?
EndIf

?
@KIX ?
@SCRIPTEXE ?

Get $RC

Here is the output on screen
 Code:
LoadKey Error
Error 5: Access is denied.
5

4.53
KIX32.EXE

I presume an undocumented feature or a bug or so?

Top
#180217 - 2007-09-06 11:09 PM Re: LoadKey problem [Re: Witto]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
Loc: CA
Well works fine for me on Server 2003 w/SP2 logged in with Admin rights.
Also tested on Windows XP w/SP2 and it worked there as well.

 Quote:
KiXtart version is: 4.53
KiXtart executable name is: KIX32.EXE
User privilege by PRIV macro: ADMIN
Reading Key ERROR: 0 - The operation completed successfully.
Value read from HKLM\SOFTWARE\TEST_KIX was: this is a sample
Saving Key ERROR: 0 - The operation completed successfully.
Loading Key ERROR: 0 - The operation completed successfully.


 Code:
Dim $RC, $Key, $File
? 'KiXtart version is: ' + @kix
? 'KiXtart executable name is: ' + @ScriptExe
? 'User privilege by PRIV macro: ' + @Priv
$Key = 'HKLM\SOFTWARE\TEST_KIX'
$File = 'C:\TEMP\KIX_TEST.REG'
$RC = ReadValue($Key,'Sample')
? 'Reading Key ERROR: ' + @ERROR + ' - ' + @SERROR 
? 'Value read from ' + $Key ' was: ' + $RC

$RC = SaveKey($Key,$File)
? 'Saving Key ERROR: ' + @ERROR + ' - ' + @SERROR

$RC = LoadKey($Key,$File)
? 'Loading Key ERROR: ' + @ERROR + ' - ' + @SERROR

Top
#180218 - 2007-09-06 11:29 PM Re: LoadKey problem [Re: NTDOC]
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
Windows XP SP2
 Code:
KiXtart version is: 4.53
KiXtart executable name is: KIX32.EXE
User privilege by PRIV macro: ADMIN
Reading Key ERROR: 2 - The system cannot find the file specified.
Value read from HKLM\SOFTWARE\TEST_KIX was:
Saving Key ERROR: 0 - The operation completed successfully.
Loading Key ERROR: 5 - Access is denied.

Top
#180219 - 2007-09-06 11:37 PM Re: LoadKey problem [Re: Witto]
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
I forgot to create a Value called sample
 Code:
KiXtart version is: 4.53
KiXtart executable name is: KIX32.EXE
User privilege by PRIV macro: ADMIN
Reading Key ERROR: 0 - The operation completed successfully.
Value read from HKLM\SOFTWARE\TEST_KIX was: aaa
Saving Key ERROR: 0 - The operation completed successfully.
Loading Key ERROR: 5 - Access is denied.

Top
#180221 - 2007-09-07 03:32 AM Re: LoadKey problem [Re: Witto]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
Loc: CA
Don't know what to say - as you can see it worked fine for me on 2 different systems using the same version of KiXtart.

Only difference I can think of is that both are on a Domain and I used an Enterprise Admin account, otherwise should work.

Try rebooting and testing it again maybe.

Top
#180229 - 2007-09-07 09:01 AM Re: LoadKey problem [Re: NTDOC]
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1894
Loc: Hilversum, The Netherlands
Witto, yeah although I ment to say ReadValue to check, and WriteValue for if the check didn't pan out. I detest loading keys anyway :P

Btw, a policy might be blocking the importing of keys, use rsop.msc to see if that is the case. Also try reg.exe see if that works (from the help command)
 Quote:

Console Registry Tool for Windows - version 3.0
Copyright (C) Microsoft Corp. 1981-2001. All rights reserved


REG LOAD KeyName FileName

KeyName ROOTKEY\SubKey (local machine only)
ROOTKEY [ HKLM | HKU ]
SubKey The key name to load the hive file into. Creating a new key
FileName The name of the hive file to load
You must use REG SAVE to create this file

Examples:

REG LOAD HKLM\TempHive TempHive.hiv
Loads the file TempHive.hiv to the Key HKLM\TempHive


Edited by apronk (2007-09-07 09:21 AM)
Edit Reason: Added reg explanation

Top
Page 1 of 2 12>


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

Who's Online
0 registered and 248 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.078 seconds in which 0.026 seconds were spent on a total of 14 queries. Zlib compression enabled.

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