How to create a Key inside the user GUID?

0

How to create a regitry key inside the user GUID? I need to do this by VBS, it will run on 500 users more or less.

Original key, for example:

HKEY_CURRENT_USER\Identities\{GUID}\Software\Microsoft\Internet Account Manager\Accounts\00000006

I need to create a key (00000099) below the "Accounts" beside the key "00000006".

mdoria

Posted 2015-09-15T19:39:30.290

Reputation: 3

Answers

0

You can work with registry keys where you don't know the name in advance using the wmi registry provider

It has a method EnumKey that will give you all subkeys for a given key. You can use this to get all identities like this:

Const HKCU = &H80000001 'HKEY_CURRENT_USER
Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\./root/default:StdRegProv")

sBaseKey = "Identities\"

iRC = oReg.EnumKey(HKCU, sBaseKey, aSubKeys)

For Each sKey In aSubKeys
    Msgbox sKey
Next

As soon as you know the identity you can build the full path you need with it and create your key using the CreateKey method. You could even use the normal RegWrite method for the key creation at this point but as you already have the StdRegProv object, I'd just use that.

Syberdoor

Posted 2015-09-15T19:39:30.290

Reputation: 1 364

It Works! I have the key... – mdoria – 2015-09-23T12:03:23.743

Thankyou It Works! I have the key!

I trying to write subkeys with RegWrite... but i dont have sucess...

Set WshShell = WScript.CreateObject("WScript.Shell") WshShell.RegWrite "HKCU\Identities"&sKey&"\Software\Microsoft\Internet Account Manager\Accounts", "00000099"

I'm trying... – mdoria – 2015-09-23T12:14:24.600

I forogt how crazy RegWrite is in that regards. If you want to use it you would have to write WshShell.RegWrite "HKCU\Identities"&sKey&"\Software\Microsoft\Internet Account Manager\Accounts\00000099", "", "REG_SZ" thus creating a default value as an empty string which is not 100% standard but would probably work. If you want it 100% correct use CreateKey or create a dummy reg_Sz under 00000099 and delete it – Syberdoor – 2015-09-23T12:26:09.690

Tks for response, I really dont know much of it.

It's working. The only problem is that the key "00000099" is being created in the wrong place.

It seems que the RegWrite can not read the full adress with the "&sKey&" in the middle .

See the situation: http://imageshack.com/a/img538/7536/WzpUZj.jpg

– mdoria – 2015-09-23T13:01:28.483

This could happen if you write the regWrite outside of the For...Next. You should either just insert that regwrite in the loop, or if you want to use the key for different stuff that should not be looped you have to save it. Like in the loop have guid = sKey. In the code above the sKey variable is only valid for the time of the loop. After the loop it is empty – Syberdoor – 2015-09-23T14:04:13.127