如何使用Windows命令行,收在firefox最后一个标签 [英] How to close last tab in firefox using windows command line
问题描述
我创建一个批处理文件来处理Firefox的标签。
我想用Windows命令来关闭Firefox中的最后一个标签。
I am creating a batch file to handle firefox tabs. I want to close the last tab in firefox using windows command.
我一直在使用的标题名称试过这个命令
I have tried this command using title name
taskkill /IM firefox.exe /FI "WindowTitle eq localhost*"
它关闭所有窗口
我有搜索在Windows命令,没有直接的方法。
有没有可能性?
I have searched in windows command, there are no direct way. Is there any possibilities ?
推荐答案
您将不得不使用VBScript code发送<大骨节病>控制骨节病> + <大骨节病>是W 骨节病>键Firefox浏览器。
You will have to use VBScript code to send Ctrl+w keys to Firefox.
保存此code作为 closeActiveTab.vbs
和在批处理运行CSCRIPT closeActiveTab.vbs
文件或嵌入code里面。
Save this code as closeActiveTab.vbs
and run it with cscript closeActiveTab.vbs
in your batch file or embed the code inside.
Dim Shell, WMI, query, process
Set Shell = CreateObject("WScript.Shell")
Set WMI = GetObject("winmgmts:{impersonationLevel=Impersonate}!\\.\root\cimv2")
query = "SELECT ProcessId FROM Win32_Process WHERE Name = 'firefox.exe'"
For Each process In WMI.ExecQuery(query)
Shell.AppActivate process.ProcessId
WScript.Sleep 100
Shell.SendKeys "^w"
Next
根据另一个答案。
这篇关于如何使用Windows命令行,收在firefox最后一个标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!