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 error stated as "Registry root is invalid", but running Test Complete as Administrator, the problem got solved. Now, that the script is getting executed registry is not getting updated. Please help.
function Test_FWC_UTL_Registry_Write_Registry_Key_Value()
{
var strKey
strKey = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon"
FWC_UTL_Registry_Write_Registry_Key_Value (strKey, "DefaultUsername", "REG_SZ", "XXXXXXXX")
}
function FWC_UTL_Registry_Write_Registry_Key_Value(strRegistryKey, strRegName, strRegType, strRegKeyValue)
{
var WshShellObj,OutputVal
WshShellObj = Sys["OleObject"]("Wscript.Shell")
OutputVal = 0
if (WshShellObj == null)
{
GL_ErrMessage = "Couldn't able to create Shell object"
}
else
{
WshShellObj.RegWrite(strRegistryKey + "\\" + strRegName , strRegKeyValue, aqString["ToUpper"](strRegType))
WshShellObj = null
OutputVal = 1
return OutputVal;
}
}
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.htmTo 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.