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)
LVL 13
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

no matter if you have administrator rights - start regedt32 and check the security settings on that "path" - maybe its set to readonly
Mark_FreeSoftwareAuthor Commented:

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?

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

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

Mark_FreeSoftwareAuthor Commented:

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

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

put MsgBox path

Is path correct? Could you post it here.
Mark_FreeSoftwareAuthor Commented:

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?
Mark_FreeSoftwareAuthor Commented:

no only that one

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

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.
Mark_FreeSoftwareAuthor Commented:

and when i use createprocess or when i inject my code into an system process like explorer?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Mark_FreeSoftwareAuthor Commented:

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.
Mark_FreeSoftwareAuthor Commented:

do you know how gpedit.msc works?
because that program can change the keys without an admin pass
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?
Mark_FreeSoftwareAuthor Commented:

>>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
Mark_FreeSoftwareAuthor Commented:

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.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.