import org.codehaus.groovy.scriptom.*;
Scriptom.inApartment
{
locator = new ActiveXObject("WbemScripting.SWbemLocator")
service = locator.ConnectServer()
drives = service.ExecQuery("select * from Win32_LogicalDisk")
for(drive in drives){
// ドライブ名とドライブタイプを取得
driveTypes = [
"Unknown", // 0:Unknown
"No Root Directory", // 1:No Root Directory
"Removable Disk", // 2:Removable Disk
"Local Disk", // 3:Local Disk
"Network Drive", // 4:Network Drive
"Compact Disc", // 5:Compact Disc
"RAM Disk", // 6:RAM Disk
]
println(drive.name + " - " + driveTypes[drive.driveType]);
}
}
実行結果例
C: - Local Disk
D: - Compact Disc
E: - Local Disk
G: - Local Disk
動作環境
JDK6 Update14, groovy1.6.3
関連情報
http://msdn.microsoft.com/en-us/library/aa394173%28VS.85%29.aspx
0 件のコメント:
コメントを投稿