我正在尝试创建一个清除Chrome中所有浏览器数据的vbscript,然后关闭所有chrome窗口。 我在关闭单词和前景时遇到了麻烦。 这是迄今为止工作的代码并清除chrome并关闭chrome浏览器:
Set WshShell = CreateObject("WScript.Shell")
set WshShell=WScript.CreateObject("WScript.Shell")
WshShell.run "chrome.exe"
Set WshShell = CreateObject("WScript.Shell")
set WshShell=WScript.CreateObject("WScript.Shell")
WshShell.run "chrome.exe"
WScript.Sleep (1000)
WScript.CreateObject("WScript.Shell").SendKeys("^h")
WScript.Sleep (2000)
WScript.CreateObject("WScript.Shell").SendKeys("{TAB}")
WScript.CreateObject("WScript.Shell").SendKeys("{TAB}")
WScript.CreateObject("WScript.Shell").SendKeys("{TAB}")
WScript.CreateObject("WScript.Shell").SendKeys("{ENTER}")
WScript.Sleep (2000)
WScript.CreateObject("WScript.Shell").SendKeys("{TAB}")
WScript.CreateObject("WScript.Shell").SendKeys("{TAB}")
WScript.CreateObject("WScript.Shell").SendKeys("{TAB}")
WScript.CreateObject("WScript.Shell").SendKeys("{TAB}")
WScript.CreateObject("WScript.Shell").SendKeys("{TAB}")
WScript.CreateObject("WScript.Shell").SendKeys("{TAB}")
WScript.CreateObject("WScript.Shell").SendKeys("{TAB}")
WScript.CreateObject("WScript.Shell").SendKeys("{TAB}")
WScript.CreateObject("WScript.Shell").SendKeys("{TAB}")
WScript.CreateObject("WScript.Shell").SendKeys("{ENTER}")
WshShell.AppActivate("Google Chrome")
WshShell.run "RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 8"
WshShell.run "RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 2"
WshShell.run "RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 1"
WshShell.run "RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 16"
WshShell.run "RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 32"
WshShell.run "RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 255"
Set objExec = Nothing : Set objShell = Nothing
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcessList = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = 'Chrome.exe'")
Set oShell = CreateObject("WScript.Shell")
For Each objProcess in colProcessList
oShell.Run "taskkill /im chrome.exe", , True
Next
Set objShell = CreateObject("WScript.Shell")
Set objExec = objShell.Exec("tasklist /fi " & Chr(34) & "imagename eq chrome.exe" & Chr(34))
If Not InStr(1, objExec.StdOut.ReadAll(), "INFO: No tasks", vbTextCompare) Then
objShell.Run "taskkill /f /t /im chrome.exe", 0, True
End If
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcessList = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = 'notepad.exe'")
For Each objProcess in colProcessList
objProcess.Terminate()
Next
我试图关闭所有单词文档并保存它们,基本上(控制s)。我希望所有这些都发生在一个VBS文件中,以便我可以将它发送给我的朋友,他们可以轻松地使用它。 我在网上研究过,但还没找到我要找的东西。 我查看过的所有网站都有,只显示如何关闭所有文档而不保存它们,或者没有在VBS中显示过程,而是使用VBA或其他脚本语言。 如果有人能帮我写我的剧本,我将不胜感激!
:)
答案 0 :(得分:0)
保存并关闭所有文件:
QGraphicsView
关闭所有文档而不保存更改QGraphicsScene
至'get a handle to the already running Word instance
On Error Resume Next
Set wd = GetObject(, "Word.Application")
On Error Goto 0
If Not IsEmpty(wd) Then
For Each doc In wd.Documents
doc.Save
doc.Close
Next
wd.Quit
End If
。这基本上告诉Word"这个文件已经保存,关闭"。