Kaseya Community

Agent Procedure to run a .reg file

  • Hi --

    I'm trying to create a simple agent procedure to run a .reg file that has a mix of HKCU and HKLM keys.  It is being run on 64-bit Windows machines.  I've tried Execute Shell Command regedit.exe /s C:\xyz\file.reg, setting it to Run As System.  VSA reports success, but the keys still don't get imported.

    Any assistance would be much appreciated. Thanks. 

  • Perhaps give the native setRegistry commands in the Agent.Procedure editor a try rather than setting via command line?

    help.kaseya.com/.../9050000

    setRegistryValue() / set64BitRegistryValue()

  • The problem is it’s a moderately large file with dozens of registry keys, and I didn’t create it.  Trying to recreate that line by line would be time consuming and likely induce many errors.

  • Fair enough. I can understand that.

    With your "Execute Shell Command", you said you've got it set to "Run as System" ....
    Have you tested setting that run-as section to "Execute as System in 64-bit Shell"

    This is selectable in the drop-down ... seeing as you're using the procedure on 64-bit Windows systems?

    executeShellCommand ("<MyCommand>", "Execute as System in 64-bit Shell", "All_OS", "Halt on Fail")



    added formatting for example
    [edited by: will.yeoh at 9:44 PM (GMT -7) on Sep 3, 2020]
  • Tried that, but it doesn't appear to have worked.  Procedure log reports Success Then, but the result of the reg import (software license renewal) didn't happen.

  • Just run the DOS reg add command for each entry works fine

    ExecuteShellcmd

    REG ADD "HKLM\System\CurrentControlSet\Services\CSC\Parameters" /v FormatDatabase /t REG_DWORD /d 1 /f 



    REG ADD "HKLM\System\CurrentControlSet\Services\CSC\Parameters" /v FormatDatabase /t REG_DWORD /d 1 /f
    [edited by: brian@saguarotech.com at 9:00 AM (GMT -7) on Sep 4, 2020]
  • if you want we can have a look together? debug a litle

  • Note that if your reg file contains keys for HKCU, then "execute as system" will not result in showing up in the actual current user's (logged in user) registry.

  • I believe you can also have the .reg run as a parameter for regedit.exe... like this;

    regedit.exe /S yourFile.reg

    I would include full path, like this;

    #vAgentConfiguration.agentTempDir#\regedit.exe /S #vAgentConfiguration.agentTempDir#\yourFile.reg

    Also, make sure you ONLY run this on the exact OS and version you exported the .reg from.