Link to home
Start Free TrialLog in
Avatar of Mark_FreeSoftware
Mark_FreeSoftwareFlag for Netherlands

asked on

Registry acces denied?


whenever i try to change a registry key in the policy part of the registry, i get an acces denied error

ret = RegCreateKeyEx(HKCU, path, 0&, "", 0&, KEY_ALL_ACCESS, ByVal 0&, Result, Disp)

after running this, it will return 5 in ret


is there a way to change the rights?

i have been looking for AdjustToken, but i don't know what token to choose, since the shutdown token found everywhere on the Inet isnt helping me


500 points and a grade of A because i am really stuck with this (and i think it is difficult)
SOLUTION
Avatar of AmigoJack
AmigoJack

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Mark_FreeSoftware

ASKER


i shall take a look at it tomorrow (i'm at another pc right now)


maybey this helps:

when i edit the settings with gpedit.msc it can change them

is that possible if they are read- only?
Avatar of amit_g
Try

ret = RegCreateKeyEx(HKCU, path, 0&, vbNullString, 0&, KEY_ALL_ACCESS, 0&, Result, Disp)

the vbnullstring doesnt work, and it seems that they are not readonly (i can only check it from the key above, because the subkey we are speaking about is DisableRegistryTools so i can't view it when it is enabled
Before

ret = RegCreateKeyEx(HKCU, path, 0&, vbNullString, 0&, KEY_ALL_ACCESS, 0&, Result, Disp)

put MsgBox path

Is path correct? Could you post it here.

this is my path "Software\Microsoft\Windows\CurrentVersion\Policies\System"

but when the path isnt correct, it shouldnt return error 5

and HKCU value is correct? It should be &H80000001.

There is nothing wrong in the code as such. This key also would be present and the user would also have access to this key. Does this happen with any key?

no only that one


is there a way to run my program with the system privileges?
What is the user that executes this?

a limited account

(but if it is possible it has to work always)
That might be the problem. First verify if this is the problem by running the program with an admin account. If it works, you know it is rights issue.

You could use RunAs batch command but that would mean that user has to enter the password.

and when i use createprocess or when i inject my code into an system process like explorer?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial

especially the createprocessasuser looks nice, but there are two problems

when i distribute an app that asks for the adminPass, people will not like it,
and the examples from msdn are written in c (my knowledge is not enough to convert that to vb)

>>when i distribute an app that asks for the adminPass, people will not like it,

That is something you have to decide. If you need admin access only whil installing, there are ways around it but all those involve pust install from Active Directory or some software from domain server. So basically it is remote installed by domain admin and thus will have admin access. If you need admin access while the program is run, you need the password accessible to the program.

>>the examples from msdn are written in c

That can be worked.


do you know how gpedit.msc works?
because that program can change the keys without an admin pass
Avatar of AmigoJack
AmigoJack

gpedit.msc is a form for ms management console... i have to ask again what you really want. set the registry value from above at any given price?

>>at any price.....

not any price, but i would like to have that done
you havent answered the rest. but since both LogonUser and CreateProcessAsUser dont work for you (you could hardcode the password into the script although that is killing the security) im finally giving up - i simply dont meet the point where something does not function as you want it


what about a split, do you guys both agree with that?
thats ok if you want to have it that way
Fine with me too.