windows脚本GUI
虽然系统提供了WScript和CScript两个脚本宿主,分别负责窗口环境和命令行环境下的脚本运行,但实际上窗口环境下用户与脚本交互不太方便:参数输入只能建立快捷方式或弹出InputBox对话框,输出信息后只有在用户“确定”后才能继续运行。完全没有了窗口环境直观、快捷的优势。好在有前面提到的InternetExplorer对象,脚本可以提供web风格的GUI。
还是来看个例子,一个清除系统日志的脚本,顺便复习一下WMI:
set ie=wscript.createobject(\”internetexplorer.application\”,\”event_\”) \’创建ie对象\’
ie.menubar=0 \’取消菜单栏\’
ie.addressbar=0 \’取消地址栏\’
ie.toolbar=0 \’取消工具栏\’
ie.statusbar=0 \’取消状态栏\’
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 \’以下调用document.write方法,\’
.write \”<html><body bgcolor=#dddddd scroll=no>\” \’写一段html到ie窗口中。\’
.write \”<h2 align=center>远程清除系统日志</h2><br>\”
.write \”<p>目标IP:<input id=ip type=text size=15>\” \’也可以用navigate方法直接打开一\’