2

So I'm using this peice of code to open an image on our display computer

"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --fullscreen --app=https://google.com

It works great!

However, the challenge is that I want to wait ~20 hours and then close that same window that opened, without closing the other chrome tabs. Any ideas?

Maybe I capture the PID when I launch this and then bring back the PID for a close?

Daniel Williams
  • 167
  • 1
  • 10
  • Hey, I think this may be out of scope (of PowerShell or Batch) but can you use other tools? I reckon a simple console app in C# or Java that uses Selenium can do the trick. – Lam Le Sep 26 '18 at 14:16

1 Answers1

2

You can accomplish this fairly easily in powershell:

$app = Start-Process -FilePath "${Env:ProgramFiles(x86)}\Google\Chrome\Application\chrome.exe" -ArgumentList '--fullscreen', '--app=https://wwwgoogle.com' -PassThru

Start-Sleep -Seconds (60 * 20)

Stop-Process -Id $app.Id
Maximilian Burszley
  • 18,243
  • 4
  • 34
  • 63
  • 1
    I get the following error: `Cannot find a process with the process identifier`. Chrome may be immediately restarting the process for some reason. Another approach using PInvoke may be required. https://stackoverflow.com/a/25792444/3608792 – Dan Wilson Sep 25 '18 at 21:22
  • @DanWilson I had a typo in my answer where I forgot the leading dashes to a parameter. – Maximilian Burszley Sep 25 '18 at 22:10
  • I doubt it makes a difference. Did you run this with a short sleep interval? The reported process ID is gone as soon as the process is started. Chrome 69. – Dan Wilson Sep 25 '18 at 22:13