#!c:\WINDOWS\system32\cscript.exe /nologo "C:\wamp\cgi-bin\vbscript_cgi.vbs"

''''''''''''''''''''''''''''''
'' testscript.vbs           ''
'' Kevin DEHLINGER          ''
'' 2007 / dev.pulsed.net    ''
'' query some data with     ''
'' wmi/wsh (some of thecode ''
'' comes from scriptomatic) ''
''''''''''''''''''''''''''''''


print "Content-type: text/html" & vbcrlf


print "<!DOCTYPE html PUBLIC ""-//W3C//DTD HTML 4.01//EN"" \""http://www.w3.org/TR/html4/strict.dtd"">" & vbcrlf & _
"<html>" & _
"<head>" & _ 
"  <meta content=""text/html; charset=ISO-8859-1"""  & _
" http-equiv=""content-type"">"  & _
"  <title></title>" & _
"</head>" & _
"<body>"


Set mycgivars=GetCgiVars

if mycgivars.exists("computer") then
computer=mycgivars.item("computer")
else
computer = "."
end if 

print "<form method=""post"" action=""testscript.vbs"" name=""test"">Computer: <input" & _
" name=""computer"" value=""" & computer & """><input" & _
" type=""submit""></label></form>" 


On Error Resume Next
Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20

println "Computer: " & computer & "<br \><br \>"


   Set objWMIService = GetObject("winmgmts:\\" & computer & "\root\CIMV2")
   Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_LogicalDisk", "WQL", _
                                          wbemFlagReturnImmediately + wbemFlagForwardOnly)

   For Each objItem In colItems
      println "Drive: " & objItem.Caption & "<br \>"
      println "Description: " & objItem.Description & "<br \>"
      println "VolumeName: " & objItem.VolumeName & "<br \>"
     println   "<br \>"
   Next



print "</body></html>"

Function WMIDateStringToDate(dtmDate)
print dtm: 
	WMIDateStringToDate = CDate(Mid(dtmDate, 5, 2) & "/" & _
	Mid(dtmDate, 7, 2) & "/" & Left(dtmDate, 4) _
	& " " & Mid (dtmDate, 9, 2) & ":" & Mid(dtmDate, 11, 2) & ":" & Mid(dtmDate,13, 2))
End Function

