Need to remotely open Chrome Settings Help in foreground using powershell

Anu B 6 Reputation points
2022-01-31T07:47:44.09+00:00

I have a requirement to run a script everyday and automatically update "Chrome Browser" if a new version is released. I am using a powershell script that goes like this:

Add-Type -Path "C:\seleniumdrivers\webdriver.dll" 
$ChromeDriver = New-Object OpenQA.Selenium.Chrome.ChromeDriver 
$ChromeDriver.Navigate().GoToURL("chrome://settings/help") 

If I execute this manually on my system or manually on VM System X, it works (chrome opens, settings > help opens).

But if I execute this as a Powershell task via TFS > Release definition > Powershell Task to execute on system X, this opens chrome as a Background Process in that system X.

How do I get Chrome Browser to open in the foreground and not as background process? Please help !

Additional Information:

I wasn't able to navigate to "Chrome Settings Help" by using any other powershell command like Start-Process "chrome.exe" "www.google.com" etc. The above seems to be the only way.

Chrome settings help can also be opened by using SendKeys, but not using that due to the unreliability of send keys.

There is a scheduled task on system X which runs GoogleUpdate.exe every one hour which inturn updates google chrome if a new version is available. BUT, recently this Scheduled Task ran (checked all logs) on the system X but it didn't update the latest 97 version, even after a day. This is the reason why I'm preferring to run a Powershell script for the same.

Also preferring to automate this as we have some automated Selenium test cases running on system X which need to always run on latest Chrome browser with latest Chrome driver. Any non sync between versions of browser and Driver will fail the test cases. This is why preferring to automate it (even though its suggested to upgrade Chrome manually)

please help !

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,628 questions
0 comments No comments
{count} vote

1 answer

Sort by: Most helpful
  1. Tomasz Dabrowski 6 Reputation points
    2022-10-10T14:05:35.897+00:00

    for someone who will be looking for
    but it brings a lot of challenges

    $proc = 'Chrome'
    Start-Process $proc
    Start-Sleep 5
    $wshell = New-Object -ComObject wscript.shell;
    $wshell.AppActivate("$proc")
    Start-Sleep 1
    $wshell.SendKeys('chrome://settings/help')
    Start-Sleep 1
    $wshell.SendKeys("{ENTER}")

    2 people found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.