NOTICE: Our Community is moving. Get more information. Updated information on a New Login Process
When calling the Reg_() functions using the Silk Test Open agent you may receive an ' Unexpected NULL' error, like so:
[ ] *** Error: Unexpected NULL[ ] Occurred in RegCreateKeyEx at Registry.inc(397)[ ] Called from Reg_CreateKey at Registry.inc(109)
The reason for this is that the Reg_ functions cannot be called by the Open agent because the agent does not support the ‘Agent.GetOption (OPT_USE_ANSICALL)' calls in the function.
To resolve this issue there are currently several workarounds.
1. Switch to the Classic agent like so.
[ ] Connect("(local)", CLASSIC_AGENT) //connect to Classic agent[ ] Reg_CreateValue (HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows\CurrentVersion\RunOnce", "Test", "hello")[ ] Connect("(local)", OPEN_AGENT)//Connect back to Open agent
2. Have SilkTest execute a .reg file to create the value.
a. Create a registry file ( silk.reg) like so
Windows Registry Editor Version 5.00
b. Create a batch file that executes a .reg file to complete the registry updates. In this example we create a file (silkreg.bat ) as seen below
regedit /s c:\silk.reg
c. Now in your script create a Sys_Execute call that the Open agent will call to create the registry value.
[-] testcase run() appstate none [ ] LIST OF STRING lsDirOut [ ] SYS_Execute("c:\silkreg.bat", lsDirOut) [ ] This will ensure the a key called 'Test' is created with the value data 'Hello'
3. Open the registry.inc file and comment any references to the Agent GetOption/SetOption calls in the relevant functions as seen below. This will allow the Open Agent to make the calls successfully.
[-] LONG RegCreateKeyEx (LONG hKey, STRING lpSubKey, LONG Reserved, STRING lpClass, LONG dwOptions, LONG samDesired, LONG lpSecurityAttributes, out LONG phkResult, out LONG lpdwDisposition) [ ] LONG retVal [-] // if (Agent.GetOption (OPT_USE_ANSICALL)) [ ] // Agent.SetOption (OPT_USE_ANSICALL, FALSE) [ ] // retVal = RegCreateKeyExW (hKey, lpSubKey, Reserved, lpClass, dwOptions, samDesired, lpSecurityAttributes, phkResult, lpdwDisposition) [ ] // Agent.SetOption (OPT_USE_ANSICALL, TRUE) [-] // else [ ] retVal = RegCreateKeyExW (hKey, lpSubKey, Reserved, lpClass, dwOptions, samDesired, lpSecurityAttributes, phkResult, lpdwDisposition) [ ] return retVal