Hello, I want to retrieve the value of a property in the Windows registry via UiPath. I wrote a PowerShell script, and when I run the script in PowerShell on my machine, it works fine. However, I can’t retrieve a registry value with UiPath Studio 21.10. I tested with the Invoke Power Shell activity, but it returns message 2: “The specified path does not exist.” I then used a VBNet script with the Invoke Code activity, but it also returns message 2: “The specified property does not exist.” Has anyone encountered the same issue? If so, do you have an example of a UiPath project that retrieves data from a registry, please? Thank you for your solutions.
The PowerShell script:
$path = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{EBBCFFE8-62F0-4F4B-B0C4-D5DC4015D7AD}'
$propertyName = 'DisplayVersion' # Replace with the name of the property you want to retrieve
if (Test-Path -Path $path) {
$item = Get-ItemProperty -Path $path -Name $propertyName
if ($null -ne $item) {
$value = $item.$propertyName
Write-Output "$propertyName : $value"
} else {
Write-Output "The specified property does not exist."
}
} else {
Write-Output $path "The specified path does not exist."
Use Invoke code activity and enter the below code by clicking on Edit Code button.
Dim path As String = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{EBBCFFE8-62F0-4F4B-B0C4-D5DC4015D7AD}"
Dim propertyName As String = "DisplayVersion"
Try
Using regKey As RegistryKey = Registry.LocalMachine.OpenSubKey(path)
If regKey IsNot Nothing Then
Dim value As Object = regKey.GetValue(propertyName)
If value IsNot Nothing Then
' Use Log Message activity to print the result
result = $"{propertyName} : {value}"
Else
' Use Log Message activity to print the result
result = "The specified property does not exist."
End If
Else
' Use Log Message activity to print the result
result = $"The specified path does not exist: {path}"
End If
End Using
Catch ex As Exception
' Use Log Message activity to print the error
result = $"An error occurred: {ex.Message}"
End Try
@ashokkarale , i try it, but got the same message : The specified path does not exist: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall{EBBCFFE8-62F0-4F4B-B0C4-D5DC4015D7AD}
i try with this path too : HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall{EBBCFFE8-62F0-4F4B-B0C4-D5DC4015D7AD}
same error. Does UiPath Studio need permissions to access the Windows registry?