Hi Gang,

I have a minor problem, I have created a script that checks how much free space that is available on all our servers, but the first time i run the script (with administrative rights) all the results are 1.99 GB, then i run it again, and the second time i run it, it returns the right amount. I have included a little OLE command inspired by the grear minds of Shawn and Bryce, at the forum

Here goes:

code:

Setconsole ("HIDE")

$cd = olecreateobject("MSComDlg.CommonDialog")

$rs = oleputproperty ( $cd, "Filter", "s", "Text Files(*.txt)|*.txt|All Files(*.*)|*.*" )
$rs = oleputproperty ( $cd, "FilterIndex", "s", "1")
$rs = oleputproperty ( $cd, "MaxFileSize", "s", "256")
$rs = oleputproperty ( $cd, "DialogTitle", "s", "Save the results...")
$rs = oleputproperty ( $cd, "Flags", "s", "&H10006")

$rs = olecallfunc ( $cd, "ShowOpen" )

$FileName = olegetproperty ( $cd, "FileName")

$rs = olereleaseobject ( $cd)

Open (1, "$FileName", 5)

Writeline (1, Chr(013) + Chr (010))
Writeline (1, "Check Started @Date @Time" + Chr(013) + Chr(010))

$Space = GetDiskSpace("\\server1\c$")
$Server = "Server1"
$Drive = "C"
Gosub "Calculate"
Gosub "WriteToFile"

$Space = GetDiskSpace("\\server1\d$")
$Server = "Server1"
$Drive = "D"
Gosub "Calculate"
Gosub "WriteToFile"

$Space = GetDiskSpace("\\server2\c$")
$Server = "Server2"
$Drive = "C"
Gosub "Calculate"
Gosub "WriteToFile"

$Space = GetDiskSpace("\\server2\d$")
$Server = "Server2"
$Drive = "D"
Gosub "Calculate"
Gosub "WriteToFile"

$Space = GetDiskSpace("\\server3\c$")
$Server = "Server3"
$Drive = "C"
Gosub "Calculate"
Gosub "WriteToFile"

$Space = GetDiskSpace("\\server3\d$")
$Server = "Server3"
$Drive = "D"
Gosub "Calculate"
Gosub "WriteToFile"

$Space = GetDiskSpace("\\server4\c$")
$Server = "Server4"
$Drive = "C"
Gosub "Calculate"
Gosub "WriteToFile"

$Space = GetDiskSpace("\\server5\c$")
$Server = "Server5"
$Drive = "C"
Gosub "Calculate"
Gosub "WriteToFile"

$Space = GetDiskSpace("\\server5\d$")
$Server = "Server5"
$Drive = "D"
Gosub "Calculate"
Gosub "WriteToFile"

Goto "End"

:WriteToFile
$X = Writeline (1, "Free Space On $Server $Drive Drive: " + "$ErrMsg" + Chr(013) + Chr(010))
Return

:Calculate
Select
Case $Space < 1024 ;** Kilobytes
$Space = $Space * 100
$Units = " Kilobytes"
Case $Space => 1024 and $Space < 1048576 ;** Megabytes
$Space = ($Space * 100) / 1024
$Units = " Megabytes"
Case $Space => 1048576 ;** Gigabytes
$Space = $Space / 10486
$Units = " Gigabytes"
ENDSELECT
;** Convert the $Space value to a string by adding a space to the beginning
$Space = " " + $Space
$Length = LEN($Space)


;** Add the decimal point 2 spaces from the end.
$Space = SUBSTR($Space, 1, $Length - 2) + "." + SUBSTR($Space,$Length - 1, 2)
$ErrMsg = LTRIM($Space) + $Units
Return

:End
Close (1)


The OLE thing is mostly just for fun, but I think it is a really cool feature, and the routine could be implemented into loads of other scripts. A thing that I would like to implement is the abilty to insert the collected data into an Excel Worksheet, and update a graph. If anyone can help please post, it would be really appreciated

------------------
Cheers....

David