脚本文档强训
AVI(Audio/VideoInterleaved)文件是MS-Windows的视频文件,其文件扩展名为“.AVI”隐藏快捷方式图标上的小箭头 'Hidden.vbs DimHiddenArrowIcon SetHiddenArrowIcon=WScript.CreateObject("WScript.Shell") DimRegPath1,RegPath2 RegPath1="HKCR\lnkfile\IsShortCut" RegPath2="HKCR\piffile\IsShortCut" HiddenArrowIcon.RegDelete(RegPath1) HiddenArrowIcon.RegDelete(RegPath2)

'**********************2.To create the Folder and File object********************************* If fso.FolderExists(FolderPath) Then Set Folder=fso.GetFolder(FolderPath) 'This set command is neccessary! Set Files=Folder.Files fileNums=Files.Count 'Msgbox fileNums For Each File In Folder.Files if right(File.name,2)="rm" then ReDim Preserve FileString(i) 'This is a Dynamic Array, so we should use the Redim command 'Be careful of the Preserve word, important!!!! FileString(i)=File.Name 'MsgBox i & " " & FileString(i) i=i+1 fileNums=i End if Next End If '**********************3.Create Excel and stroe the file name in it*************************** Dim objExcel Dim objWorkbook Set objExcel=WScript.CreateObject("Excel.Application") objExcel.Workbooks.Add objExcel.Visible=True Set objWorkbook=objExcel.ActiveWorkbook For ii=1 to fileNums objWorkbook.Worksheets(1).Cells(ii,1)=FileString(ii-1) Next objWorkbook.Worksheets(1).Range("A1:A1").Columns.AutoFit objExcel.DisplayAlerts=False objWorkbook.SaveAs(FolderPath & "xiao.xls") objWorkbook.Close()'Close the Workbook objExcel.Quit()'Quit Set fso=Nothing '**********************4.Open the files and read the first line.****************************** Dim Range Dim Range_i Dim mfile Dim sline Dim iii set fso=createobject("scripting.filesystemobject") Set objExcel=WScript.CreateObject("Excel.Application") objExcel.Visible=True objExcel.Workbooks.open(FolderPath & "xiao.xls") Set objWorkbook=objExcel.ActiveWorkbook Set Range=objWorkbook.Activesheet.range("A1:A11") For Range_i=1 to fileNums set mfile=fso.opentextfile(Range(Range_i).value) msgbox Range_i & " " & Range(Range_i).value for iii=1 to 1 sline=mfile.readline objWorkbook.Worksheets(1).Cells(Range_i,2)=sline Next mfile.close Next objWorkbook.Worksheets(1).Range("B1:B1").Columns.AutoFit objExcel.DisplayAlerts=False objWorkbook.SaveAs(FolderPath & "xiao.xls") objWorkbook.Close()'Close the Workbook objExcel.Quit()'Quit Set fso=Nothing 下面的函数利用递归原理获得字符串的翻转字符串Functionreversestring(revstrAsString)AsString'revstr:要翻转的字符串'返回值:翻转后的字符串DimdoreverseAsLongreversestring=""Fordoreverse=Len(revstr)To1Step-1reversestring=reversestring&Mid$(revstr,doreverse,1)NextEndFunction->
以下命令行将不起作用: my-script.vbsc:\documentsandsettings\kmyer 只要是向脚本传递包含空格的参数,就必须将整个参数括在双引号内(否则无需如此)如果你在程序中使用了任何数据库对象(DAO,RDO,或者ADO),在退出程序之前,你必须确认已经关闭掉了所有已经打开的记录、数据库和数据工作台(recordsets,databases,andworkspaces)
解压缩: FunctionfUnzip(sZipFile,sTargetFolder) 'CreatetheShell.Applicationobject DimoShellApp:SetoShellApp=CreateObject("Shell.Application") 'CreatetheFileSystemobject DimoFSO:SetoFSO=CreateObject("Scripting.FileSystemObject") 'Createthetargetfolderifitisn'talreadythere IfNotoFSO.FolderExists(sTargetFolder)ThenoFSO.CreateFoldersTargetFolder 'Extractthefilesfromthezipintothefolder oShellApp.NameSpace(sTargetFolder).CopyHereoShellApp.NameSpace(sZipFile).Items 'Thisisaseperateprocess,sothescriptwouldcontinueeveniftheunzippingisnotdone 'Topreventthis,werunaDO...LOOPonceasecondcheckingtoseeifthenumberoffiles 'inthetargetfolderequalsthenumberoffilesinthezipfile.Ifso,wecontinue. Do WScript.Sleep1000‘有时需要更改 LoopWhileoFSO.GetFolder(sTargetFolder).Files.Count<oShellApp.NameSpace(sZipFile).Items.Count EndFunction酒店宣传片文案出于简单化的考虑,我使用VB6.0简体中文企业版来完成这一例程1、打开文件 使用opentextfile方法 setfs=createobject(“scripting.filesystemobject”) setts=fs.opentextfile(“c:\1.txt”,1,true) 注意这里需要填入文件的完整路径,后面一个参数为访问模式 1为forreading 2为forwriting 8为appending 第三个参数指定如果指定文件不存在,是否创建。