收藏 分享(赏)

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

上传人:kpmy5893 文档编号:7134158 上传时间:2019-05-06 格式:DOC 页数:16 大小:67KB
下载 相关 举报
Windows脚本编程核心技术精解-随书示例脚本-第十三章.doc_第1页
第1页 / 共16页
Windows脚本编程核心技术精解-随书示例脚本-第十三章.doc_第2页
第2页 / 共16页
Windows脚本编程核心技术精解-随书示例脚本-第十三章.doc_第3页
第3页 / 共16页
Windows脚本编程核心技术精解-随书示例脚本-第十三章.doc_第4页
第4页 / 共16页
Windows脚本编程核心技术精解-随书示例脚本-第十三章.doc_第5页
第5页 / 共16页
点击查看更多>>
资源描述

1、 13-1.VBS2 13-2.VBS4 13-3.VBS6 13-4.VBS8 13-5.VBS10 13-6.VBS12 13-7.VBS15 13-1.VBS-the following lines have been added to ensure all required COM objects are available on your system. script uses the following components: scripting.filesystemobject wscript.shellCheckCOM-end of COM-object checking co

2、de-set args = WScript.Argumentsif args.Count=0 thenMsgBox “Please drag a vbs script file on my icon.“ _& “ Ill place it into the Startup group!“WScript.Quitend ifset fs = CreateObject(“Scripting.FileSystemObject“)set wshshell = CreateObject(“WScript.Shell“)scriptfile = args(0)if not lcase(fs.GetExte

3、nsionName(scriptfile)=“vbs“ thenMsgBox “I only accept vbs script files!“WScript.Quitend ifstartup = wshshell.SpecialFolders(“Startup“)name = InputBox(“Under which name should I place the script “ _& “ & fs.GetBaseName(scriptfile) & “ into the StartUp-“ _& “Group?“, “autostart script“)set scut = wshs

4、hell.CreateShortcut(startup & “ & name & “.lnk“)scut.TargetPath = scriptfilescut.SaveMsgBox “Script has been successfully linked to your StartUp group!“ - the following code had been automatically added to ensure all required COM objects are installed.function COMExists(name) checks whether a specif

5、ic COM object is installed on your local machineset cwsh = CreateObject(“WScript.Shell“)on error resume nextdummy = cwsh.RegRead(“HKCR“ & name & “)if err.number0 thenCOMExists = falseelseCOMExists = trueend ifend functionsub CheckCOMif not COMExists(“scripting.filesystemobject“) thenmsg=“COM-Object

6、“scripting.filesystemobject“ is required. This object is currently not installed on your system.“ & vbCrmsg = msg & “Reinstall the Windows Scripting Host!“ & vbCrMsgBox msg, vbExclamationend ifif not COMExists(“wscript.shell“) thenmsg=“COM-Object “wscript.shell“ is required. This object is currently

7、 not installed on your system.“ & vbCrmsg = msg & “Reinstall the Windows Scripting Host!“ & vbCrMsgBox msg, vbExclamationend ifend sub- end of COM object checking code (C) 2000 by Dr. T. Weltner - all rights reserved. 13-3.VBS-the following lines have been added to ensure all required COM objects ar

8、e available on your system. script uses the following components: wscript.shellCheckCOM-end of COM-object checking code-set wshshell = CreateObject(“WScript.Shell“)key = “HKLMSoftwareMicrosoftWindowsCurrentVersionRun“ use this key on Windows NT/2000:key = “HKLMSoftwareMicrosoftWindows NTCurrentVersi

9、onRun“wshshell.RegDelete key & “myscript“MsgBox “Deleted script entry from Registry.“ - the following code had been automatically added to ensure all required COM objects are installed.function COMExists(name) checks whether a specific COM object is installed on your local machineset cwsh = CreateOb

10、ject(“WScript.Shell“)on error resume nextdummy = cwsh.RegRead(“HKCR“ & name & “)if err.number0 thenCOMExists = falseelseCOMExists = trueend ifend functionsub CheckCOMif not COMExists(“wscript.shell“) thenmsg=“COM-Object “wscript.shell“ is required. This object is currently not installed on your syst

11、em.“ & vbCrmsg = msg & “Reinstall the Windows Scripting Host!“ & vbCrMsgBox msg, vbExclamationend ifend sub- end of COM object checking code (C) 2000 by Dr. T. Weltner - all rights reserved. 13-6.VBS-the following lines have been added to ensure all required COM objects are available on your system.

12、 script uses the following components: wscript.shellCheckCOM-end of COM-object checking code-set wshshell = CreateObject(“WScript.Shell“) find out the script file you want to use as command extensionset args = WScript.Argumentsif args.Count=0 thenMsgBox “Please drag a vbs script file onto my script

13、icon!“WScript.Quitend if did I receive a vbs file?if not lcase(Mid(args(0), InstrRev(args(0), “.“)=“.vbs“ thenMsgBox “I only accept vbs script files!“WScript.Quitend if which file type do you want to append?filetype = InputBox(“Please enter the file extension for the “ _& “file type you want to add

14、a context menu command to!“, _, “.vbs“)if not left(filetype,1)=“.“ then filetype = “.“ & filetype find out whether this key existson error resume nextprgkey = wshshell.RegRead(“HKCR“ & filetype & “) file type unknown!if not err.number=0 thenMsgBox “File Type “ & filetype & “ is unknown!“WScript.Quit

15、end ifon error goto 0 insert this key as new context menu command:name = InputBox(“How do you want to call your new command?“, _,“Show size“) start with this keykey1 = “HKCR“ & prgkey & “shell“ insert command namewshshell.RegWrite key1 & name & “, name insert commandwshshell.RegWrite key1 & name & “

16、command“, _“wscript.exe “ & “ & args(0) & “ & “ “%L“MsgBox “New command installed successfully!“ - the following code had been automatically added to ensure all required COM objects are installed.function COMExists(name) checks whether a specific COM object is installed on your local machineset cwsh

17、 = CreateObject(“WScript.Shell“)on error resume nextdummy = cwsh.RegRead(“HKCR“ & name & “)if err.number0 thenCOMExists = falseelseCOMExists = trueend ifend functionsub CheckCOMif not COMExists(“wscript.shell“) thenmsg=“COM-Object “wscript.shell“ is required. This object is currently not installed o

18、n your system.“ & vbCrmsg = msg & “Reinstall the Windows Scripting Host!“ & vbCrMsgBox msg, vbExclamationend ifif not COMExists(“clip.board“) thenmsg=“COM-Object “clip.board“ is required. This object is currently not installed on your system.“ & vbCrmsg = msg & “Install the CLIPBOARD component from CD“ & vbCrMsgBox msg, vbExclamationend ifend sub- end of COM object checking code (C) 2000 by Dr. T. Weltner - all rights reserved.

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 企业管理 > 管理学资料

本站链接:文库   一言   我酷   合作


客服QQ:2549714901微博号:道客多多官方知乎号:道客多多

经营许可证编号: 粤ICP备2021046453号世界地图

道客多多©版权所有2020-2025营业执照举报