亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

VBS腳本也有GUI圖形界面 日志清除功能

 更新時(shí)間:2011年01月19日 21:52:37   投稿:mdxy-dxy  
讓VBS腳本也有GUI圖形界面,主要是利用了vbs中的internetexplorer.application組件,實(shí)現(xiàn)打開一個(gè)ie頁面。

使用方法:將下面的代碼保存為rizhi.vbs雙擊運(yùn)行即可,如果不行可能是殺毒軟件的問題。可以搜索下。腳本之家以前提供過解決方法。

set ie=wscript.createobject("internetexplorer.application","event_") '創(chuàng)建ie對(duì)象' 
ie.menubar=0 '取消菜單欄' 
ie.addressbar=0 '取消地址欄' 
ie.toolbar=0 '取消工具欄' 
ie.statusbar=0 '取消狀態(tài)欄' 
ie.width=400 '寬400' 
ie.height=400 '高400' 
ie.resizable=0 '不允許用戶改變窗口大小' 
ie.navigate "about:blank" '打開空白頁面' 
ie.left=fix((ie.document.parentwindow.screen.availwidth-ie.width)/2) '水平居中' 
ie.top=fix((ie.document.parentwindow.screen.availheight-ie.height)/2) '垂直居中' 
ie.visible=1 '窗口可見' 

with ie.document '以下調(diào)用document.write方法,' 
.write "<html><body bgcolor=#dddddd scroll=no>" '寫一段html到ie窗口中。' 
.write "<h2 align=center>遠(yuǎn)程清除系統(tǒng)日志</h2><br>" 
.write "<p>目標(biāo)IP:<input id=ip type=text size=15>" '也可以用navigate方法直接打開一' 
.write "<p>用戶名:<input id=user type=text size=30>" '個(gè)html文件,效果是一樣的。' 
.write "<p>密碼: <input id=pass type=password size=30>" 
.write "<p align=center>類型:" '不僅是input對(duì)象,所有DHTML支持' 
.write "<input id=app type=checkbox>應(yīng)用程序 " '的對(duì)象及其屬性、方法都可以使用。' 
.write "<input id=sys type=checkbox>系統(tǒng) " 
.write "<input id=sec type=checkbox>安全" '訪問這些對(duì)象的辦法和網(wǎng)頁中訪問' 
.write "<p align=center><br>" '框架內(nèi)對(duì)象是類似的。' 
.write "<input id=confirm type=button value=確定> " 
.write "<input id=cancel type=button value=取消>" 
.write "</body></html>" 
end with 

dim wmi '顯式定義一個(gè)全局變量' 
set wnd=ie.document.parentwindow '設(shè)置wnd為窗口對(duì)象' 
set id=ie.document.all '設(shè)置id為document中全部對(duì)象的集合' 
id.confirm.onclick=getref("confirm") '設(shè)置點(diǎn)擊"確定"按鈕時(shí)的處理函數(shù)' 
id.cancel.onclick=getref("cancel") '設(shè)置點(diǎn)擊"取消"按鈕時(shí)的處理函數(shù)' 

do while true '由于ie對(duì)象支持事件,所以相應(yīng)的,' 
wscript.sleep 200 '腳本以無限循環(huán)來等待各種事件。' 
loop 

sub event_onquit 'ie退出事件處理過程' 
wscript.quit '當(dāng)ie退出時(shí),腳本也退出' 
end sub 

sub cancel '"取消"事件處理過程' 
ie.quit '調(diào)用ie的quit方法,關(guān)閉IE窗口' 
end sub '隨后會(huì)觸發(fā)event_onquit,于是腳本也退出了' 

sub confirm '"確定"事件處理過程,這是關(guān)鍵' 
with id 
if .ip.value="" then .ip.value="." '空ip值則默認(rèn)是對(duì)本地操作' 
if not (.app.checked or .sys.checked or .sec.checked) then 'app等都是checkbox,通過檢測其checked' 
wnd.alert("至少選擇一種日志") '屬性,來判斷是否被選中。' 
exit sub 
end if 
set lct=createobject("wbemscripting.swbemlocator") '創(chuàng)建服務(wù)器定位對(duì)象' 
on error resume next '使腳本宿主忽略非致命錯(cuò)誤' 
set wmi=lct.connectserver(.ip.value,"root/cimv2",.user.value,.pass.value) '連接到root/cimv2名字空間' 
if err.number then '自己捕捉錯(cuò)誤并處理' 
wnd.alert("連接WMI服務(wù)器失敗") '這里只是簡單的顯示“失敗”' 
err.clear 
on error goto 0 '仍然讓腳本宿主處理全部錯(cuò)誤' 
exit sub 
end if 
if .app.checked then clearlog "application" '清除每種選中的日志' 
if .sys.checked then clearlog "system" 
if .sec.checked then clearlog "security" '注意,在XP下有限制,不能清除安全日志' 
wnd.alert("日志已清除") 
end with 
end sub 

sub clearlog(name) 
wql="select * from Win32_NTEventLogFile where logfilename='"&name&"'" 
set logs=wmi.execquery(wql) '注意,logs的成員不是每條日志,' 
for each l in logs '而是指定日志的文件對(duì)象。' 
if l.cleareventlog() then 
wnd.alert("清除日志"&name&"時(shí)出錯(cuò)!") 
ie.quit 
wscript.quit 
end if 
next 
end sub

上面是通過vbs輸出html內(nèi)容來實(shí)現(xiàn),一般情況下,腳本之家小編是使用hta來實(shí)現(xiàn)圖像界面。

相關(guān)文章

最新評(píng)論