Windows脚本编程核心技术精解-随书示例脚本-第十八章.doc
上传人:qw****27 上传时间:2024-09-12 格式:DOC 页数:6 大小:31KB 金币:15 举报 版权申诉
预览加载中,请您耐心等待几秒...

Windows脚本编程核心技术精解-随书示例脚本-第十八章.doc

Windows脚本编程核心技术精解-随书示例脚本-第十八章.doc

预览

在线预览结束,喜欢就下载吧,查找使用更方便

15 金币

下载此文档

如果您无法下载资料,请参考说明:

1、部分资料下载需要金币,请确保您的账户上有足够的金币

2、已购买过的文档,再次下载不重复扣费

3、资料包下载后请先用软件解压,在使用对应软件打开

TOC\*MERGEFORMAT'18-01.VBSPAGEREF_Toc261789441\h2'18-2.VBSPAGEREF_Toc261789442\h3'18-3.VBSPAGEREF_Toc261789443\h5'18-01.VBSsetinputstream=WScript.StdInsetoutputstream=WScript.StdOutdodata=inputStream.ReadLineifdata="exit"thenWScript.Quitelseoutputstream.WriteLineUCASE(data)endifloop'18-2.VBS'---thefollowinglineshavebeenaddedtoensureallrequiredCOMobjectsareavailableonyoursystem.'scriptusesthefollowingcomponents:'wscript.shellCheckCOM'---endofCOM-objectcheckingcode---'whichenginerunsthisscript?engine=lcase(mid(WScript.FullName,InstrRev(WScript.FullName,"\")+1))ifnotengine="cscript.exe"then're-launchscriptusingcscript.exesetwshshell=CreateObject("WScript.Shell")wshshell.run"CSCRIPT.EXE"""&WScript.ScriptFullName&""""WScript.QuitendifMsgBox"IrunasDOS-Box!"'---thefollowingcodehadbeenautomaticallyaddedtoensureallrequiredCOMobjectsareinstalled.functionCOMExists(name)'checkswhetheraspecificCOMobjectisinstalledon'yourlocalmachinesetcwsh=CreateObject("WScript.Shell")onerrorresumenextdummy=cwsh.RegRead("HKCR\"&name&"\")iferr.number<>0thenCOMExists=falseelseCOMExists=trueendifendfunctionsubCheckCOMifnotCOMExists("wscript.shell")thenmsg="COM-Object""wscript.shell""isrequired.Thisobjectiscurrentlynotinstalledonyoursystem."&vbCrmsg=msg&"ReinstalltheWindowsScriptingHost!"&vbCrMsgBoxmsg,vbExclamationendifendsub'---endofCOMobjectcheckingcode'(C)2000byDr.T.Weltner-allrightsreserved.'18-3.VBS'---thefollowinglineshavebeenaddedtoensureallrequiredCOMobjectsareavailableonyoursystem.'scriptusesthefollowingcomponents:'wscript.shellCheckCOM'---endofCOM-objectcheckingcode---setwshshell=CreateObject("WScript.Shell")'setcscript.exeasstandardwshshell.run"WSCRIPT.EXE//H:CScript"'launchcommandwindowandwaitok=wshshell.run("""%comspec%""",,true)'changebacktodefaultwshshell.run"WSCRIPT.EXE//H:WScript"'---thefollowingcodehadbeenautomaticallyaddedtoensureallrequiredCOMobjectsareinstalled.functio