google chrome - Close Specific Website with Stop-Process in PowerShell -


I was thinking that anyone is a way to turn off the specific website that the user has opened in Google Chrome ?

So far, I have Google Chrome open on a website that is in user type. The site $ question variable is assigned to that you will see below:

  $ Question2 = Reed-host "Do you want to copy $ back to the server?" If ($ question 2 -i 'yes') -or (($ Question 2 -i 'yes') -or ($ question 2 -ec 'yes') -or ($ question2 -ec 'y') -or ($ Question 2 - Eq 'Y') or ($ Question 2 - EC 'Y')) {start chrome.exe http: //$question.website.org/}  

I am wondering what is there a way, when Chrome opens on that website, then I can also close it.

I know

Stop-Process Proprietary Name Chrome

But it will close Chrome all at once.

Any suggestion is appreciated.

Thanks in advance!

It is very difficult to believe me. It seems that when Chrome starts, it produces many other processes that end up on the windows / tab and the process you actually start allows only this and then comes out. I thought it could be possible to open a new window and track the PID of that program, but the PID that disappears quickly, it disappears.

I also thought that it could be possible that you can see the ProcessStartInfo information whether you can pass any argument through the argument which you can ask later, but then when You launch the process, and arguments are not passed to the logical processes.

What's the price, how far away I got it:

[PS] 118 # $ A = New Object System Diagnostics. Process [PS] 119 # $ A.startinfo.filename = "C: \ Program Files (x86) \ Google \ chrome \ application \ chrome.exe" [PS] 120 # $ a.startinfo.arguments = "--new- Window http: // google .com "[PS] 121 # $ a.startinfo.useshellexecute = $ false [PS] 122 # $ a.startinfo.verb =" test "[PS] 123 # $ a.start () true [PS] 124 # $ One Handle NPM (K) PM (K) WS (K) VM (M) CPU (S) ID Process Name ------- ----------- - --- --- - ------- ----------- 0 0 0.08 7332 [PS] 125 # Acquisition Process | ? {$ _. Id-eq 7332} [PS] 126 # Process | ? {$ _. Name -Ek 'Chrome'} | % {$ _. Startinfo.arguments} [PS] 127 #

Although this has created a new window, as you can see that the process was back, 7332 does not exist, and any StartInfo.Arguments of other chrome processes are empty

As a side to achieving this task, you use simple answer to answer yes / no for your answer Can simplify easily. Regular expression:

  ($ question2 -imatch "^ y (es)? $") ($ Question2 -imatch "no? $")  

As proven:

  [PS] 404 & gt; $ ("Y" -Match "Y (s)? $") True [PS] 405 & gt; $ ("Yes" -match "y (s)? $") True [ps] 406 & gt; $ ("N" -imatch "^ no? $") True [PS] 407 & gt; $ ("Nn" -imatch "^ no? $") Incorrect  

Comments