/build/static/layout/Breadcrumb_cap_w.png

Scripting help needed

Hi,
my below code is not working....It can create up to Location10 not more than that, please help.


'On Error Resume Next

CONST HKEY_CURRENT_USER = &H80000001

strComputer = "."

Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\default:StdRegProv")

strKeyPath = "Software\Microsoft\Office\12.0\Access\Security\Trusted Locations\"

strWriteLn = "C:\Program Files\Microsoft Office\"

strvalName = "Location"

intcount=1

Set Objshell = CreateObject("wscript.shell")

'------------------------------------------------------------------------------------------


Chk_N_Write_Line ( strWriteLn )



'------------------------------------------------------------------------------------------

Sub Chk_N_Write_Line ( strWriteLn )

objReg.EnumKey HKEY_CURRENT_USER, strKeyPath, arrSubKeys

For Each subkey In arrSubKeys

subkey1 = Replace (LCase(subkey), "location", "") 'Split(Subkey, "n")


Next

subkey1 = subkey1+intcount

strvalName = Left (strvalName,8) & subkey1

A = "HKEY_CURRENT_USER" & "\" & strkeypath & strvalName & "\Path"

objshell.regwrite A,strWriteLn, "REG_SZ"

End Sub



0 Comments   [ + ] Show comments

Answers (2)

Posted by: anonymous_9363 12 years ago
Red Belt
0
From a cursory glance at your code, it only gets up to 'Location10' because you have 10 sub-keys beneath the 'Trusted Location' key.

I'm guessing that you want to add a Trusted Location programmatically? According to what I've read about this path, the sub-keys can be called whatever you like, so long as it's unique. My gambit would be to use a GUID (there's lots of GUID-generation VBScript code around) for that prupose. Note also the 'AllowSubFolders' key, which should be a sub-key of the new 'Trusted Location' sub-key. For reference, see here.
Posted by: MadForMsi 12 years ago
Blue Belt
0
Thanks for your valuable reply.

Comments:
  • Did you work this one out? We're having the same problem with Office 2010.. Does this script enable trusted location on network drives? - KRN 12 years ago
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ