Setws=CreateObject("WScript.Shell")
SetFSO=CreateObject("Scripting.FileSystemObject")
kugou=ws.regRead("HKCUSoftwareKuGouAppPath")
ForEachfInFSO.GetFolder(kugou).Files
ext=LCase(Right(f.Name,4))
Ifext=".exe"Orext=".dll"Then
s=s&f.Name&vbTab&FSO.GetFileVersion(f.Path)&vbCrLf
EndIf
Next
MsgBoxs
2. vbs怎么得到自己的文件名
获取自身文件名的——
Dim fso,f
Set fso = CreateObject("Scripting.FileSystemObject")
f = fso.GetFile(Wscript.scriptfullname).name
--------------------------------------------------
获取自身完整路径的
Dim fso,f
Set fso = CreateObject("Scripting.FileSystemObject")
f = fso.GetFile(Wscript.scriptfullname).path
3. vbs获得当前路径所有文件夹的名称
Setfso=CreateObject("scripting.filesystemobject")
Withfso.GetFolder(".")
ForEachSBIn.SubFolders
WScript.Echosb.name
Next
EndWith
4. 如何用vbs获取指定路径下的文件名并输出到文本文件
给你写个简单的public function ReplaceStr(FilePath,ExtensioNname,Find,WreplaceStr)on error resume next '绕过读写错误dim fso,read,list set fso = createobject("scripting.filesystemobject") for each list in fso.getfolder(filepath).files '遍历文件夹 if fso.getextensionname(list)=ExtensioNname then '判断文件是否是txt,若是则执行 read=fso.opentextfile(list).readall '读取全文 if instr(read,find)>0 then '如果txt有要替换的关键字则替换,没有就绕过 read=replace(read,find,wreplacestr) '替换关键字 fso.createtextfile(list.path).write read '写入文本 end if end if next set fso=nothing '释放内存,这里注意,我没有重新设定新对象,尽量不要用以免你忘记加上close导致代码在读写时发生错误,若一定要用的时候才用,我一般是这样的end functionreplacestr "e:\1","txt",123,empty '将e:\1文件夹下的所有txt类型文件中的123初始化(即删除)
5. 通过vbs脚本或者bat脚本,实现获取文件名和文件大小等信息并输出到Excel文档
生成到EXCEL里的不会,但是可以生成CSV文件
自己建一个VBS文件,把下面的代码扔进去。
可以自己制定路径,生成C:\1.csv文件。
dim SF,sE,tF
dim fs,oF,sT
sub getFd(fd)
wrtf fd
for each tmpFd in fd.subfolders
getFd tmpFd
next
end sub
sub wrtF(fd)
for each tmpfile in fd.files
sE.write tmpfile.name & "," & tmpfile.size & vbcrlf
next
end sub
sF = InputBox("input your path")
set fs = CreateObject("Scripting.FileSystemObject")
set oF = fs.GetFolder(sF)
tF="C:\1.csv"
if fs.FileExists(tF) then
fs.DeleteFile tF
end if
set sE = fs.OpenTextFile (tF, 8, True)
sE.write "name,size" & vbcrlf
getFd oF
sE.close
msgbox "done!"