如何使用.bat文件打开和关闭chrome选项卡

问题描述 投票:0回答:1

所以我有一个只能打开chrome的.bat文件,所以现在我想在一段时间后关闭选项卡。 我确实找到了设置超时和关闭的方法,但是..

这是我的bat文件的原始代码

start cmd /c "start chrome.exe "http://localhost/home.php"

我想添加这一行

timeout /t 200 taskkill /F /IM chrome.exe /T > nul
,所以它是这样的:

start cmd /c "start chrome.exe "http://localhost/home.php" timeout /t 200 taskkill /F /IM chrome.exe /T > nul

但结果是它打开了一个名为 timeout、taskkill 和 chrome.exe 的选项卡。 opened tabs

我做错了什么?如何编辑代码,是否为每个任务添加报价?

batch-file
1个回答
0
投票

试试这个

start cmd /c "start chrome.exe http://localhost/home.php" & timeout /t 200 & taskkill /F /IM chrome.exe /T > nul

使用 & 将多个命令链接在一起

© www.soinside.com 2019 - 2024. All rights reserved.