獲得文件夾大小的VBS代碼
更新時間:2014年04月21日 23:02:58 投稿:mdxy-dxy
這篇文章主要介紹了vbs中獲得文件夾大小的代碼,需要的朋友可以參考下
核心代碼
'---------------------- '獲得文件夾的大小 'Author = baiyang 'Version = 1.0 'Date = 09.08.08 '---------------------- Option Explicit On Error Resume Next Dim objFSO, objLocalFolder, strArg, longLocalFolderSize, strSizeMess '判斷是不是沒有路徑參數(shù) If WScript.Arguments.Count < 1 Then WScript.Echo "參數(shù)無效, 第一個參數(shù)為路徑" WScript.Quit Else strArg = WScript.Arguments(0) End If Set objFSO = CreateObject("Scripting.FileSystemObject") Set objLocalFolder = objFSO.GetFolder(strArg) If objLocalFolder = Empty Then WScript.Echo "Invalid Path" WScript.Quit End If longLocalFolderSize = objLocalFolder.Size If longLocalFolderSize>=1024 And longLocalFolderSize<1024*1024 Then strSizeMess = Round( longLocalFolderSize/1024, 3 ) & " K" ElseIf longLocalFolderSize>=1024*1024 And longLocalFolderSize<1024*1024*1024 Then strSizeMess = Round( longLocalFolderSize/1024/1024, 3 ) & " M" ElseIf longLocalFolderSize>=1024*1024*1024 Then strSizeMess = Round( longLocalFolderSize/1024/1024/1024, 3 ) & " G" Else strSizeMess = longLocalFolderSize & " B" End If WScript.Echo strSizeMess Set objFSO = Nothing Set objLocalFolder = Nothing WScript.Quit
使用方法:
將上面的挨罵保存文件為: GetFloderSize.vbs
用法: GetFloderSize.vbs C:\windows即可。
相關(guān)文章
VBS教程:函數(shù)-DateValue 函數(shù)
VBS教程:函數(shù)-DateValue 函數(shù)...2006-11-11VBS 強制關(guān)閉Symantec Endpoint Protection的代碼
很多企業(yè)電腦系統(tǒng)是Windows Xp,使用Windows server 2003 來控制,其中客戶端得殺毒軟件有不少是使用 Symantec Endpoint Protection2013-01-01使用 Iisext.vbs 刪除應(yīng)用程序依存關(guān)系的實現(xiàn)方法
這篇文章主要介紹了使用 Iisext.vbs 刪除應(yīng)用程序依存關(guān)系的實現(xiàn)方法,需要的朋友可以參考下2014-07-07