Scripting help needed
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)
Please log in to answer
Posted by:
anonymous_9363
12 years ago
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.
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
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.
so that the conversation will remain readable.