Tip: Set SAP GUI Scripting Registry Entries

The approach I followed for the GUI Info for SAP activity was to read the registry entries to make sure they were set correctly before running a workflow. The correct setting of the options in SAP Logon should actually be done via central control. However, it is also possible to set the options during the workflow. In this tip, I show how an Invoke Code activity can be used to implement this.

In a normal case the settings in the SAP GUI Logon for the Scripting should looks like this:

To ensure that these settings are guaranteed, the following C# code can be used in an Invoke Code activity:

// UiPath Invoke Code Begin---------------------------------------------

const string userRoot = "HKEY_CURRENT_USER";
string regKey = "\\Software\\SAP\\SAPGUI Front\\SAP Frontend Server\\Security";
string keyName = userRoot + regKey;

Microsoft.Win32.Registry.SetValue(keyName, "UserScripting",
  in_UserScripting, Microsoft.Win32.RegistryValueKind.DWord);
Microsoft.Win32.Registry.SetValue(keyName, "WarnOnAttach",
  in_WarnOnAttach, Microsoft.Win32.RegistryValueKind.DWord);
Microsoft.Win32.Registry.SetValue(keyName, "WarnOnConnection",
  in_WarnOnConnection, Microsoft.Win32.RegistryValueKind.DWord);

regKey = "\\Software\\SAP\\SAPGUI Front\\SAP Frontend Server\\Scripting";
keyName = userRoot + regKey;
Microsoft.Win32.Registry.SetValue(keyName, "ShowNativeWinDlgs",
  in_ShowNativeWinDlgs, Microsoft.Win32.RegistryValueKind.DWord);

// UiPath Invoke Code End-----------------------------------------------

Here the extracted workflow:
SetSAPGUIScriptingRegistryEntries.xaml (7.3 KB)

Here the main workflow:

SetSAPGUIScriptingRegistryEntries.zip (162.1 KB)

With this approach is it possible to set the SAP GUI Scripting settings in the registry at the runtime of a workflow. You can find all possible registry entries of the SAP GUI in the SAP GUI Administration Guide. With minor adjustments, this approach allows any setting of the SAP GUI for Windows at runtime of a workflow.

1 Like