VBS Simple Script Help

Joined
25 Sep 2011
Posts
3,859
Hey Guys,

Been years since i've done any vb stuff and google isnt helping much.

I have the following:

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colDisks = objWMIService.ExecQuery _
("Select * from Win32_LogicalDisk Where DeviceID = 'C:'")
For Each objDisk in colDisks
intFreeSpace = objDisk.FreeSpace
intTotalSpace = objDisk.Size
pctFreeSpace = intTotalSpace / 100 * 35
Wscript.Echo pctFreeSpace
Next

This outputs the value of 35% of the free disk space on C.

However it outputs it as "36846225203.2". I need this output as just the first 5 digits (36846) and I cannot figure out how.

Any help would be much appreciated.
 
If you need a smaller number, why not calculate a smaller percentage?

I need that specific percentage (just part of a bigger script).


Yeah I did see that link in my googling but couldn't figure it out.

I'm now a very noob scripter having forgotten almost everything I use to know!

Anyway, it's now working as I need with Six's suggestion.

Thanks for the help.
 
Yes I see what you mean touch - and you are correct.

However for the purpose of this, it shouldn't actually matter..

The number outputted here is then taken and inputted in to set the cache size for the sccm client.

The client itself works on mb so just taking the first 5 digits will be fine as this does not need to be an exact or specific figure, just a rough percentage.

Have now tested on numerous machines its working as expected.
 
Back
Top Bottom