如何使用CMD或VBS轻轻关闭Chrome? [英] How to gently close Chrome using CMD or VBS?

查看:764
本文介绍了如何使用CMD或VBS轻轻关闭Chrome?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在轻轻关闭Chrome以自动清理缓存方面遇到一些问题。

I'm having a little problem about closing gently Chrome in order to automatically clean cache.

我的网站无法正确刷新,但是如果清理缓存,它确实可以刷新

I have a website that is not refreshing correctly, but it does if I clean the cache.

目前,我有一个.bat文件,其中包含以下代码:

For now I have a .bat file with the following code:

taskkill /F /IM chrome.exe /T > nul
del /q "C:\Users\Francisco\AppData\Local\Google\Chrome\User Data\Default\Cache\*"
FOR /D %%p IN ("C:\Users\Francisco\AppData\Local\Google\Chrome\User Data\Default\Cache\*.*") DO rmdir "%%p" /s /q
timeout 8
start chrome --restore-last-session --start-fullscreen

现在,我知道 taskkill / F 会强制关闭该过程,并且可以正常运行,但是一旦Chrome打开,它会显示一条消息,表明Chrome没有正确关闭并问我是否要还原上一个会话。

Now, I know that taskkill /F forces the process to close and that works but as soon as Chrome opens, it shows a message that Chrome wasn't closed correctly and asks me if I want to restore the last session.

如果我删除了/ f选项,Chrome不会关闭:

If i remove the /f option, Chrome doesn't close:


错误:使用PID 8580的进程(PID辅助进程8896)
无法完成。

原因:只能强制终止此进程(使用/ F选项) 。

ERROR: the process with PID 8580 (PID secondary process 8896) Could not finish.
Reason: This process can be terminated only forcibly (with the / F option).

所以...我需要两个选项之一;

So... I need one of two options;


  1. 是就像使用CMD或VBS?2按下Alt + F4一样,可以轻轻地关闭Chrome。有没有办法隐藏Chrome恢复上次会话的消息?

我更喜欢第一个选项,因为它更干净。

I'd prefer the first option since it's cleaner.

推荐答案

您可以使用powershell关闭所有使用chrome作为进程名称的窗口。它不会终止任务,但会轻轻关闭所有Chrome浏览器窗口,就像您单击右上角的十字线一样。这是要分批放入的命令行:

you can use powershell to close all windows with chrome as process name. It won't kill the task but gently close all chrome browser windows, like if you clicked on top-right cross. Here is the command line to put in batch :

powershell -command "Get-Process chrome | ForEach-Object { $_.CloseMainWindow() | Out-Null}"

这篇关于如何使用CMD或VBS轻轻关闭Chrome?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆