Scripting help needed

Author Message
MadForMsi

  • Total Posts : 13
  • Scores: 0
  • Reward points : 0
  • Joined: 11/3/2010
  • Status: offline
Scripting help needed Sunday, January 01, 2012 10:50 PM (permalink)
0
Hi,
my below code is not working....It can create up to Location10 not more than that, please help.


<message edited by MadForMsi on Sunday, January 01, 2012 11:04 PM>
 
#1
    Hackoo

    • Total Posts : 105
    • Scores: 4
    • Reward points : 0
    • Joined: 6/25/2010
    • Status: offline
    Re:Scripting help needed Monday, January 02, 2012 12:15 AM (permalink)
    0
    MadForMsi

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

    Where is your code i can't see it ?? or it's an invisible and a hidden code
     
    #2
      MadForMsi

      • Total Posts : 13
      • Scores: 0
      • Reward points : 0
      • Joined: 11/3/2010
      • Status: offline
      Re:Scripting help needed Monday, January 02, 2012 12:51 AM (permalink)
      0
      How to post a code? something is changed in this website. Whenever I am putting code, it goes in single line
       
      '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
      <message edited by MadForMsi on Monday, January 02, 2012 12:57 AM>
       
      #3
        59cobalt

        • Total Posts : 979
        • Scores: 91
        • Reward points : 0
        • Joined: 7/17/2011
        • Status: offline
        Re:Scripting help needed Tuesday, January 03, 2012 1:33 AM (permalink)
        0
        EnumKey() returns the subkey array in alphabetical order, i.e. "Location10" appears before "Location2". When you create "Location10", the next enumeration will again return "Location9" as the last element, so you'll just overwrite the already existing "Location10" subkey. To go beyond 10 you need to determine the highest location number instead of the last enumeration element:
        subkey1 = 0
        For Each subkey In arrSubKeys
         subkeyNum = Int(Replace(LCase(subkey), "location", ""))
         If subkeyNum > subkey1 Then subkey1 = subkeyNum
        Next

         
        #4

          Online Bookmarks Sharing: Share/Bookmark

          Jump to:

          Current active users

          There are 0 members and 1 guests.

          Icon Legend and Permission

          • New Messages
          • No New Messages
          • Hot Topic w/ New Messages
          • Hot Topic w/o New Messages
          • Locked w/ New Messages
          • Locked w/o New Messages
          • Read Message
          • Post New Thread
          • Reply to message
          • Post New Poll
          • Submit Vote
          • Post reward post
          • Delete my own posts
          • Delete my own threads
          • Rate post

          2000-2012 ASPPlayground.NET Forum Version 3.9