Kaseya Community

Problems writing registry entry to HKCU using regedit

  • I'm stucking using regedit with a .REG file - I need to write out a long binary and can't do it programatically (That I've found.) Problem is, I need to do this in HKCU.

    So when I double-click my .REG file when logged into the computer, it works fine.

    When I'm logged into the computer and run it through my script, no go. I'm guessing it's not registering as the proper HKCU. I even tried using the /R on regedit and pointing it the current profiles NTUSER.DAT file, nothing.

    Any thoughts?

    IF True
    THEN
    Write File
    Parameter 1 : #vAgentConfiguration.agentTempDir#\C3030bw.reg
    Parameter 2 : \C3030bw.reg
    OS Type : 0
    Execute File
    Parameter 1 : %windir%\regedit.exe
    Parameter 2 : /s #vAgentConfiguration.agentTempDir#\C3030bw.reg
    Parameter 3 : 0
    OS Type : 0
    ELSE

    Legacy Forum Name: Problems writing registry entry to HKCU using regedit,
    Legacy Posted By Username: DiPersiaTech
  • When a user is logged on there is only ever one profile loaded into the HKCU hive ...so I would say its safe that you are pointing to the correct one.

    (as a side note...Do you have fast user swithcing enabled...and other user logged in also?)

    After you run your script, are you checking the actual registry for a successful write, or are you awaiting for the desired effect on the computer somehow. For instance, running a .REG file will also cause a refresh of the desktop, but writing to the registry will not.

    Might help if you post the reg file and what it is supposed to do.

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: XeviouS
  • Also, try changing the If True to If User logged in.

    I've had an odd issue in the past where this has been the problem.

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: LANWorx
  • yes true....where ever possible I will use the IF condition 'user is logged in' a requirement for any HKCU scripts.

    So what to do with the ELSE condition then?

    Why send an email that the script couldnt run as there was no logged in user, of course!

    ;-)

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: XeviouS
  • Best use for the ELSE condition in this case is to reschedule the script to run again in 15 minutes or so. That way it will run once when the user finally logs in and your done.

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: doug.jenkins@ispire.ca