The VBS script also provides the GUI log clearing function.

Source: Internet
Author: User

Usage: Save the following code as rizhi. vbs and double-click it to run it. If not, it may be caused by anti-virus software. You can search. A solution has been provided before. Copy codeThe Code is as follows: set ie = wscript. createobject ("internetexplorer. application", "event _") 'create ie Object'
Ie. menubar = 0 'cancel menu bar'
Ie. addressbar = 0 'cancel the address bar'
Ie. toolbar = 0 'cancel toolbar'
Ie. statusbar = 0 'cancel the status'
Ie. width = 400 'width 400'
Ie. height = 400 'height 400'
Ie. resizable = 0 'do not allow users to change the window size'
Ie. navigate "about: blank" 'open blank page'
Ie.left1_fix(ie.doc ument. parentwindow. screen. availwidth-ie.width)/2) 'horizontally centered'
Ie.topdeskfix(ie.doc ument. parentwindow. screen. availheight-ie.height)/2) 'vertical Center'
Ie. visible = 1 'window visible'

With ie.doc ument 'Call the document. write method below ,'
. Write ". Write "

. Write "<p> Target IP address: <input id = ip type = text size = 15>" 'You can also use the navigate method to open'
. Write "<p> user name: <input id = user type = text size = 30>" 'html files, the effect is the same. '
. Write "<p> password: <input id = pass type = password size = 30>"
. Write "<p align = center> type:" 'not only the input object, but all DHTML support'
. Write "<input id = app type = checkbox> application" 'objects, attributes, and methods can be used. '
. Write "<input id = sys type = checkbox> System"
. Write "<input id = sec type = checkbox> Security" 'Methods for accessing these objects and webpage access'
. Write "<p align = center> <br>" 'objects in the framework are similar. '
. Write "<input id = confirm type = button value = OK>"
. Write "<input id = cancel type = button value = cancel>"
. Write "</body> End

Dim wmi 'explicitly defines a global variable'
Set wnd=ie.doc ument. parentwindow 'set wnd as the window Object'
Set id=ie.doc ument. all 'set id to the set of all objects in document'
Id. confirm. onclick = getref ("confirm") 'sets the processing function when you click "OK'
Id. cancel. onclick = getref ("cancel") 'sets the processing function when the "cancel" button is clicked'

Do while true 'because the ie Object supports events, the corresponding ,'
The wscript. sleep 200 'script waits for events in an infinite loop. '
Loop

Sub event_onquit 'ie exit event processing Process'
Wscript. quit 'when ie exits, the script also exits'
End sub

Sub cancel '"cancel" event processing Process'
Ie. quit 'Call the quit method of ie and close the IE Windows'
End sub 'will then trigger event_onquit, so the script also exits'

Sub confirm '"OK" event handling process, which is the key'
With id
If. ip. value = "" then. ip. value = "." 'null ip value indicates local operation by default'
If not (. app. checked or. sys. checked or. sec. checked) then 'app and so on are all checkboxes'
Wnd. alert ("select at least one log") 'attribute to determine whether the log is selected. '
Exit sub
End if
Set lct = createobject ("wbemscripting. swbemlocator") 'create server locating Object'
On error resume next 'make the Script Host ignore non-fatal error'
Set wmi = lct. connectserver (. ip. value, "root/cimv2",. user. value,. pass. value) 'connect to the root/cimv2 namespace'
If err. number then 'catch the error and handle the error'
Wnd. alert ("failed to connect to WMI server") 'here is a simple display of "failed "'
Err. clear
On error goto 0 'still let the Script Host handle all the errors'
Exit sub
End if
If. app. checked then clearlog "application" 'clear each selected Log'
If. sys. checked then clearlog "system"
If. sec. checked then clearlog "security" 'Note that security logs cannot be cleared due to restrictions in XP'
Wnd. alert ("log cleared ")
End
End sub

Sub clearlog (name)
Wql = "select * from Win32_NTEventLogFile where logfilename = '" & name &"'"
Set logslogs wmi.exe cquery (wql) 'note that logs members are not each log ,'
For each l in logs, but specifies the log file object. '
If l. cleareventlog () then
An error occurred while wnd. alert ("clearing logs" & name! ")
Ie. quit
Wscript. quit
End if
Next
End sub

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.