|
|
|||||||
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 |
||||||||
|
|
|||||||
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 |
||||||||
|
|
|||||||
Borrowing from the manual: Quote: On Windows NT or higher, using LOADKEY requires Backup and Restore privileges. |
||||||||
|
|
|||||||
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 |
||||||||
|
|
|||||||
Do you have Backup and Restore privileges? I think not. WriteValue() does not need Backup and Restore privileges. |
||||||||
|
|
|||||||
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. |
||||||||
|
|
|||||||
I guess: put your user id in the local group called "Backup Operators"? |
||||||||
|
|
|||||||
"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 |
||||||||
|
|
|||||||
Originally Posted By: luca I'm the "ADMINISTRATOR", I think that administrator has "Backup/Restore" permission. What do You think about? 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. |
||||||||
|
|
|||||||
Originally Posted By: Jooel "I think I have supernatural powers, thus I have them" hmm... |
||||||||
|
|
|||||||
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. |
||||||||
|
|
|||||||
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. |
||||||||
|
|
|||||||
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. |
||||||||
|
|
|||||||
Why not use ReadValue instead ? |
||||||||
|
|
|||||||
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:
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? |
||||||||
|
|
|||||||
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 |
||||||||
|
|
|||||||
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. |
||||||||
|
|
|||||||
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. |
||||||||
|
|
|||||||
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. |
||||||||
|
|
|||||||
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 |
||||||||
|
|
|||||||
Originally Posted By: NTDOC Try rebooting and testing it again maybe. |
||||||||
|
|
|||||||
apronk, Originally Posted By: apronk REG LOAD KeyName FileName I would think the equivalent for LoadKey() with reg.exe would be REG RESTORE etc... Quote: C:\>reg restore /? Console Registry Tool for Windows - version 3.0 Copyright (C) Microsoft Corp. 1981-2001. All rights reserved REG RESTORE KeyName FileName KeyName ROOTKEY\SubKey (local machine only) ROOTKEY [ HKLM | HKCU | HKCR | HKU | HKCC ] SubKey The full name of a registry key to restore the hive file into. Overwriting the existing key's values and subkeys FileName The name of the hive file to restore You must use REG SAVE to create this file Examples: REG RESTORE HKLM\Software\Microsoft\ResKit NTRKBkUp.hiv Restores the file NTRKBkUp.hiv overwriting the key ResKit |
||||||||
|
|
|||||||
Witto, you make a habit of "attempting" to correct me When I say something I mean what I say and not something I didn't say or was supposed to say :P Pretty obvious that Reg Load is more apropriate then Reg Restore, in MY point of view anyway (and no I don't mean anything other than EXACTLY what I've said, typo's included :P). |
||||||||
|
|
|||||||
The answer is simple (in my case): Close the registry editor. |