How Can get default downloads path of chrome using UiPath with out interacting with web ?
also don’t wanna use PowerShell
Hi
You can use vb code for this
Inside the “Invoke Code” activity, you can use the following VB.NET code to read the Chrome download path from the Windows Registry:
vbnet
Imports Microsoft.Win32
Public Sub GetChromeDownloadPath()
' Define the Registry key for Chrome settings
Dim keyPath As String = "Software\Google\Chrome\PreferenceMACs\Default"
Dim valueName As String = "download.default_directory"
' Read the Chrome download path from the Registry
Dim chromeDownloadPath As String = Registry.CurrentUser.OpenSubKey(keyPath).GetValue(valueName).ToString()
' Output the Chrome download path
Console.WriteLine("Chrome Download Path: " & chromeDownloadPath)
End Sub
Save the workflow, and then run it.
As another option we can go for web
If not through powershell then other option is to interact with browser’s UI
Use web automation where open browser and mimic the same set of steps u do to navigate and get the default folder details in Chrome with Ui based activities like click activity
Cheers @devanshi
No I can’t do that as but thank you any other way
I just updated with a VBA
Have a view on it
It did not work for me gives errors
Hi @devanshi
In the “Invoke Method” activity, you can use the following settings:
-
TypeArgument:
System.Management.ManagementObject
-
TargetObject: Create a new variable of type
System.Management.ManagementClass
and set it tonew System.Management.ManagementClass("Win32_Process")
. -
After the “Invoke Method” activity, add an “Assign” activity to retrieve the Chrome download directory.
-
In the “To” field of the “Assign” activity, create a variable to store the Chrome download directory. In the “Value” field, use the following expression:
downloadDirectory = (From p In New System.Management.ManagementObjectSearcher(“SELECT * FROM Win32_Process WHERE Name=‘chrome.exe’”).Get().Cast(Of System.Management.ManagementObject)()
Where p(“CommandLine”) IsNot Nothing AndAlso p(“CommandLine”).ToString().Contains(“–download-directory=”)
Select p(“CommandLine”).ToString().Split("–download-directory=“c)(1).Split(” "c)(0)).FirstOrDefault()
- After running the workflow, the
downloadDirectory
variable will contain the default downloads path of Google Chrome. You can use this variable in your workflow as needed.
Try this post,
This is not working please something else if possible
Once try this way:
- Declare a variable to store the downloads path : “downloadsPath” Of String Type
- Then Take an Assign Activity :
downloadsPath = Microsoft.Win32.Registry.GetValue(“HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders”, “Downloads”, Nothing).ToString
- Explanation of the code:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders
is the registry path where the Downloads folder location is stored. "Downloads"
is the name of the registry value that contains the path to the Downloads folder.
- Use a log message to view the path
Log Message:
Level: Info
Message: "Chrome Downloads Path: " + downloadsPath
I used this and I’m getting blank path can you suggest why and how can i get it