Forum Discussion

Mojo's avatar
Mojo
Occasional Contributor
9 years ago

Registry key is not getting added for auto Login using C# script.

Hi, I am trying to write registry key for auto login using C# script. The script is getting executed, but the registry is not getting added. My code is shown as below: Initially I was getting an erro...
  • AlexanderM's avatar
    AlexanderM
    9 years ago

    Mojo 

    They are talking about accessing the 64-bit registry from a 32-bit application on a 64-bit system. By default, a 32-bit application will be auto-directed into the Wow6432Node folder even when it does not include that part in the registry key name. That's why you did not see the value added to the path you used, but instead it appeared under Wow6432Node - TestComplete is a 32-bit application.

     

    When writing "Just add a 64 to main key", they are talking about this help file of AutoIt:
    https://www.autoitscript.com/autoit3/docs/functions/RegRead.htm

     

    To access the 64-bit registry from a TestComplete script, you can use the Storages.Registry object, like this:

     

    function Test_FWC_UTL_Registry_Write_Registry_Key_Value()
    {
    var strKey
    strKey = "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon"
    FWC_UTL_Registry_Write_Registry_Key_Value (HKEY_LOCAL_MACHINE, strKey, "DefaultUsername", "XXXXXXXX") 
    }
    
    function FWC_UTL_Registry_Write_Registry_Key_Value(regRoot, strRegistryKey, strRegName, strRegKeyValue)
    { 
    var key = Storages.Registry(strRegistryKey, regRoot, AQRT_64_BIT);
    key.SetOption(strRegName, strRegKeyValue);
    return 1;
    }

    Does this help?

     

    Also, if you can make things work manually, you will certainly be able to automate the process. That's why I suggested figuring out how to do it manually first, and then trying to turn this into code, as opposed to writing the code right away.