Registry update - the correct code

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
giovanniroi
Junior Coder
Posts: 21
Joined: Fri Jul 03, 2009 4:36 pm
Location: Milan,Italy

Registry update - the correct code

Post by giovanniroi » Tue Nov 08, 2011 9:31 am

Dear Support,
I have two different code to update the registry, I ask You what is the better way to modify the registry:

1) First code
----------------
RegistryWriteKey>HKEY_CURRENT_USER,Software\Microsoft\Office\12.0\Access\Security\Trusted Locations\Location0,Path,C:\GR&A_Trend\
REG_INTASSTR = 1
RegistryWriteKey>HKEY_CURRENT_USER,Software\Microsoft\Office\12.0\Access\Security\Trusted Locations\Location0,AllowSubfolders,1

2) Second code
-----------------
VBSTART
const HKEY_CURRENT_USER = &H80000002
strComputer = "."
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
strComputer & "\root\default:StdRegProv")
strKeyPath = "Software\Microsoft\Office\12.0\Access\Security\Trusted Locations\Location0"
strValueName1 = "Path"
strValueName2 = "AllowSubfolders"
strValue = "C:\\GR&A_Trend\\"
dwValue = &H00000001

oReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName1,strValue
oReg.SetDWORDValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName2,dwValue
VBEND
----------
Can You help me to use the correct code?

Thank's for the support

Giovanni Roi

User avatar
Marcus Tettmar
Site Admin
Posts: 7391
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Tue Nov 08, 2011 1:21 pm

Neither is "better" than the other. The first uses native Macro Scheduler functions, the second uses VBScript. However they are not working on the same key. The first acts against HKEY_CURRENT_USER while the second is updating HKEY_LOCAL_MACHINE.

Use whichever you feel more comfortable with. There is no right or wrong.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts