VBS教程:方法-GetDrive 方法
GetDrive 方法
返回與指定的路徑中驅動器相對應的 Drive 對象。
object.GetDrive drivespec
參數(shù)
object
必選項。應為 FileSystemObject 的名稱。
drivespec
必選項。drivespec 可以是驅動器號 (c)、帶冒號的驅動器號 (c:)、帶有冒號與路徑分隔符的驅動器號 (c:\) 或任何指定的網(wǎng)絡共享 (\\computer2\share1)。
說明
對于網(wǎng)絡共享,檢查并確保該網(wǎng)絡共享存在。
若drivespec與已接受格式不一致或不存在,就會出錯。為了在調(diào)用 GetDrive 方法時使用標準路徑字符串,使用下列序列得到與 drivespec 相匹配的字符串:
DriveSpec = GetDriveName(GetAbsolutePathName(Path))
下面示例說明如何使用 GetDrive 方法:
Function ShowFreeSpace(drvPath) Dim fso, d, s Set fso = CreateObject("Scripting.FileSystemObject") Set d = fso.GetDrive(fso.GetDriveName(drvPath)) s = "Drive " & UCase(drvPath) & " - " s = s & d.VolumeName & "<BR>" s = s & "Free Space: " & FormatNumber(d.FreeSpace/1024, 0) s = s & " Kbytes" ShowFreeSpace = sEnd Function
相關文章
xp、2003開3389+非net創(chuàng)建管理用戶+Shift后門+自刪除腳本vbs
喜歡VBS腳本的朋友可以下載使用。此腳本免殺,可以用于WebShell提供時使用,適用于2003系統(tǒng)和XP系統(tǒng)。2008-06-06VBS技術內(nèi)幕:CreateObject函數(shù)詳解
CreateObject函數(shù)可以說是VBS中最強大的函數(shù),沒有了它,VBS只能用來算算數(shù)學題。我們都知道CreateObject函數(shù)可以創(chuàng)建對象,但是很多人并不知道其中的奧秘2018-05-05