- 1、本文档共16页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
Windows脚编程核心技术精解-随书示例脚本-第十三章
13-1.VBS 2
13-2.VBS 4
13-3.VBS 6
13-4.VBS 8
13-5.VBS 10
13-6.VBS 12
13-7.VBS 15
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.shell
CheckCOM
---end of COM-object checking code---
set args = WScript.Arguments
if args.Count=0 then
MsgBox Please drag a vbs script file on my icon. _
Ill place it into the Startup group!
WScript.Quit
end if
set fs = CreateObject(Scripting.FileSystemObject)
set wshshell = CreateObject(WScript.Shell)
scriptfile = args(0)
if not lcase(fs.GetExtensionName(scriptfile))=vbs then
MsgBox I only accept vbs script files!
WScript.Quit
end if
startup = wshshell.SpecialFolders(Startup)
name = InputBox(Under which name should I place the script _
fs.GetBaseName(scriptfile) into the StartUp- _
Group?, autostart script)
set scut = wshshell.CreateShortcut(startup \ name .lnk)
scut.TargetPath = scriptfile
scut.Save
MsgBox 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 specific COM object is installed on
your local machine
set cwsh = CreateObject(WScript.Shell)
on error resume next
dummy = cwsh.RegRead(HKCR\ name \)
if err.number0 then
COMExists = false
else
COMExists = true
end if
end function
sub CheckCOM
if not COMExists(scripting.filesystemobject) then
msg=COM-Object scripting.filesystemobject is required. This object is currently not installed on your system. vbCr
msg = msg Reinstall the Windows Scripting Host! vbCr
MsgBox msg, vbExclamation
end if
if not COMExists(wscript.shell) then
msg=COM-Object wscript.shell is required. This object is currently not installed on your system. vbCr
msg = msg Reinstall the Windows Scripting Host! vbCr
MsgBox msg, vbExc
文档评论(0)