Results 1 to 3 of 3

Thread: Issue with amending HKLM Value

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2016
    Posts
    18

    Issue with amending HKLM Value

    Good afternoon
    I have the below script which should amend values in HKLM
    it should read the value from strvaluename and then this is the oldvalue, then set a new string value which prefixes with the strvalue

    Const HKEY_LOCAL_MACHINE = &H80000002
    strComputer = "."
    Set objRegistry = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
    strKeyPath = "SOFTWARE\Wow6432Node\Interwoven\Worksite\Client\FileSite\Commands\Workspace\"
    strValueName = "Commands"
    strValue = ",-,printBarcode.printBC@Print Barcode"
    objRegistry.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, oldValue
    newValue = oldValue & "," & strValue
    objRegistry.SetStringValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, newValue

    This works fine as HKCU as shown in the below script
    Const HKEY_CURRENT_USER = &H80000001
    strComputer = "."
    Set objRegistry = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
    strKeyPath = "Software\Microsoft\Internet Explorer\International\"
    strValueName = "AcceptLanguage"
    strValue = "en-GB;Q=0.5"
    objRegistry.GetStringValue HKEY_CURRENT_USER, strKeyPath, strValueName, oldValue
    newValue = oldValue & "," & strValue
    objRegistry.SetStringValue HKEY_CURRENT_USER, strKeyPath, strValueName, newValue


    Can anyone advise why when I alter the path to HKLM it no longer works please?
    Regards

  2. #2
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,532

    Re: Issue with amending HKLM Value

    First guess: Permissions. You are the user, so you can alter the Current User hive all you want; it's your sandbox. the LM Hive though... affects all users and the system so you need to have the appropriate admin permissions to make changes to it.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Feb 2016
    Posts
    18

    Re: Issue with amending HKLM Value

    Quote Originally Posted by techgnome View Post
    First guess: Permissions. You are the user, so you can alter the Current User hive all you want; it's your sandbox. the LM Hive though... affects all users and the system so you need to have the appropriate admin permissions to make changes to it.

    -tg

    Hi,
    thanks for this
    it will be running from a SYSTEM account so should have the relevant permissions to do so, it also doesn't run from an elevated command prompt either?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width