Forum Discussion

Mojo's avatar
Mojo
Occasional Contributor
9 years ago
Solved

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;
  }
}