[英]Close “This PC” using command line or Powershell on Windows 10
[英]How to close last tab in firefox using windows command line
我正在創建一個批處理文件來處理firefox選項卡。 我想使用windows命令關閉firefox中的最后一個選項卡。
我使用標題名稱嘗試了此命令
taskkill /IM firefox.exe /FI "WindowTitle eq localhost*"
它關閉了所有窗口
我在windows命令中搜索過,沒有直接的方法。 有可能嗎?
您必須使用VBScript代碼將Ctrl + w鍵發送到Firefox。
將此代碼保存為closeActiveTab.vbs
並在批處理文件中使用cscript closeActiveTab.vbs
運行它或將代碼嵌入其中 。
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
基於另一個答案 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.