问题
I using in the VBS file script this code for closing Chrome browser automatically
Set objExec = browobj.Exec("tasklist /fi " & Chr(34) & "imagename eq chrome.exe" & Chr(34))
If Not InStr(1, objExec.StdOut.ReadAll(), "INFO: No tasks", vbTextCompare) Then
browobj.Run "taskkill /f /t /im chrome.exe", 0, True
End If
the problem is that when i reopen the browser always with
Set browobj = CreateObject("Wscript.Shell")
siteA = "http://XXXXXXX/"
browobj.Run "chrome -url " & siteA
I have error
Google Chrome was not shut down properly
What's wrong?
Why is this happening?
回答1:
Refer to the answer of @tuxy42 : here
You can write to open chrome browser like this : Open_Chrome_Browser.vbs
Set ws = CreateObject("Wscript.Shell")
siteA = "https://stackoverflow.com/questions/62516355/google-chrome-always-says-google-chrome-was-not-shut-down-properly"
ws.Run "chrome -url " & siteA
And if you want to close it safely : safely_close_chrome_browser.vbs
Set ws = CreateObject("Wscript.Shell")
psCommand = "Cmd /C powershell -command ""Get-Process chrome | ForEach-Object { $_.CloseMainWindow() | Out-Null}"""
ws.run psCommand,0,True
来源:https://stackoverflow.com/questions/62516355/google-chrome-always-says-google-chrome-was-not-shut-down-properly