locked
vbscript to create percentage disk partition regardless of disk size RRS feed

  • Question

  • Hey Script Gurus,

    Does anyone has an idea how to create percentage disk partition regardless of disk size in vbscript.

    Basically, I would use it as a script for diskpat.exe /s for my customized imaging project without using MDT or SCCM.

    I found a script from other web site, what it does is 50/50 equal disk partition regardless of disk size.

    But I would like to change it to percentage like 70/30 or 80/20 but could not figure out how to.

    I hope you guys can help me with my query.

    Thank you! Cheers!


    Saturday, April 30, 2016 11:39 AM

Answers

  • It is simple arithmetic.'

    "size * .3" will give you 30 percent of the total size.

    "size - (size * .3)" will give you the remaining 70 percent.


    \_(ツ)_/


    • Edited by jrv Sunday, May 1, 2016 4:47 PM
    • Marked as answer by Nick.Rock Tuesday, May 3, 2016 4:36 PM
    Sunday, May 1, 2016 4:46 PM

All replies

  • Post you script.

    I really don't see why you cannot figure it out.  THe arithmentic fo 70/30 is the same as 50/50.

    50/50 is time 1/2 and 70/30 is times .3 and times .7


    \_(ツ)_/

    Saturday, April 30, 2016 1:29 PM
  • Thanks for the reply. actually i'm not that of a coding guy. If you could help on the below script that would be much appreciated. This actually works for 50/50. 

    Function FindDrive()
    Dim strComputer
    Dim objWMIService
    Dim colDisks
    Dim objDisk
    Dim strSize
    Dim total

    strComputer = "."
    Set objWMIService = GetObject("winmgmts:" _
        & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
    Set colDisks = objWMIService.ExecQuery _
        ("Select * from Win32_LogicalDisk Where DriveType = 3")
    For Each objDisk in colDisks
    total = total + CDbl(objDisk.Size)
    strSize = Int(((total /1024)/ 1024) /2)
    Next

    FindDrive = strSize
    End Function


    Sunday, May 1, 2016 3:53 PM
  • It is simple arithmetic.'

    "size * .3" will give you 30 percent of the total size.

    "size - (size * .3)" will give you the remaining 70 percent.


    \_(ツ)_/


    • Edited by jrv Sunday, May 1, 2016 4:47 PM
    • Marked as answer by Nick.Rock Tuesday, May 3, 2016 4:36 PM
    Sunday, May 1, 2016 4:46 PM
  • Thank you jrv. Much appreciated
    Tuesday, May 3, 2016 4:36 PM
  • You are welcome.  Sometimes difficult things turnout to be simple.  We just need to find a different way to ask the question.

    \_(ツ)_/

    Tuesday, May 3, 2016 4:48 PM