Google Chrome always says, “Google Chrome was not shut down properly” [duplicate]

余生长醉 提交于 2020-06-27 04:18:20

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!