See the top rated post in this thread. Click here

Results 1 to 5 of 5

Thread: Lisp to get Drive Size and Free Space of C drive

  1. #1
    I could stop if I wanted to
    Join Date
    2001-10
    Location
    Defragging the internets.
    Posts
    350
    Login to Give a bone
    0

    Default Lisp to get Drive Size and Free Space of C drive

    I can create a bat file to find total Volume size and Free space of C drive (creates username text file). I could push this out to our users when they open a file, but the cmd window flashes for a second and would be annoying.

    Does anyone know of a way to get this type of information with-in AutoCAD?
    Or, does anyone know how to start a bat file hidden (invisible)?

    This is the code I can use to start the bat file:
    Code:
    (startapp "J:\\ServerFolder\\Drive_Space\\free_space.bat")
    Any help would be appreciated,
    Chris

  2. #2
    Administrator rkmcswain's Avatar
    Join Date
    2004-09
    Location
    Earth
    Posts
    9,803
    Login to Give a bone
    1

    Default Re: Lisp to get Drive Size and Free Space of C drive

    If you don't mind using a 3rd party tool, then the (dos_chkdsk) function in DOSLIB does what you want.
    It will return 3 values: total disk space, used disk space, and free disk space. DOSLIB has dozens and dozens of other cool functions like this.

    If you want to avoid using a 3rd party tool, then you can do it like this:

    Code:
    (defun foo ( / fso drive fs m)
      (vl-load-com)
      (setq	fso    (vlax-create-object "Scripting.FileSystemObject"))
      (setq drive  (vlax-invoke-method fso 'GetDrive "C"))
      (setq fs     (vlax-get-property drive 'FreeSpace))
      (setq m      (vlax-variant-value fs))
      (rtos m 2 2)
    )
    Similar code can be used to find the total size, etc.
    R.K. McSwain | CAD Panacea |

  3. #3
    Member
    Join Date
    2001-03
    Location
    ROMANIA
    Posts
    35
    Login to Give a bone
    0

    Default Re: Lisp to get Drive Size and Free Space of C drive

    An other approach is by using DOSLib from here: http://wiki.mcneel.com/doslib/home

  4. #4
    Administrator rkmcswain's Avatar
    Join Date
    2004-09
    Location
    Earth
    Posts
    9,803
    Login to Give a bone
    0

    Default Re: Lisp to get Drive Size and Free Space of C drive

    Quote Originally Posted by LiDo View Post
    An other approach is by using DOSLib from here: http://wiki.mcneel.com/doslib/home
    That is what I said in post 2.
    R.K. McSwain | CAD Panacea |

  5. #5
    I could stop if I wanted to
    Join Date
    2001-10
    Location
    Defragging the internets.
    Posts
    350
    Login to Give a bone
    1

    Default Re: Lisp to get Drive Size and Free Space of C drive

    Quote Originally Posted by rkmcswain View Post
    If you don't mind using a 3rd party tool, then the (dos_chkdsk) function in DOSLIB does what you want.
    It will return 3 values: total disk space, used disk space, and free disk space. DOSLIB has dozens and dozens of other cool functions like this.

    If you want to avoid using a 3rd party tool, then you can do it like this:

    Code:
    (defun foo ( / fso drive fs m)
      (vl-load-com)
      (setq	fso    (vlax-create-object "Scripting.FileSystemObject"))
      (setq drive  (vlax-invoke-method fso 'GetDrive "C"))
      (setq fs     (vlax-get-property drive 'FreeSpace))
      (setq m      (vlax-variant-value fs))
      (rtos m 2 2)
    )
    Similar code can be used to find the total size, etc.
    Thanks!!
    This is what I ended up with:
    Code:
    (defun foo ( / fso drive fs m)
      (vl-load-com)
      (setq	fso    (vlax-create-object "Scripting.FileSystemObject"))
      (setq drive  (vlax-invoke-method fso 'GetDrive "C"))
      (setq fs     (vlax-get-property drive 'FreeSpace))
      (setq m      (vlax-variant-value fs))
      (setq GBfree  (strcat (rtos(* 0.000000001 m)2 2)" GB free space on C_drive"))
    (setq HDFS (strcat  "J:\\TEMP\\Drive_Space\\" (getvar "loginname")".txt"))
    (setq File#1 (open HDFS "w"))
    (write-line GBfree File#1)
    (close File#1))
    (foo)

    Thanks again,
    Chris

Similar Threads

  1. Map Drive Letter with LISP?
    By vsheehan in forum AutoLISP
    Replies: 2
    Last Post: 2013-10-01, 12:03 PM
  2. Not enough space on C drive
    By mbalsom in forum Revit Architecture - General
    Replies: 10
    Last Post: 2010-06-28, 08:52 PM
  3. running out of hard drive space with network rendering
    By steve.butler.211968 in forum 3ds Max - General
    Replies: 6
    Last Post: 2009-05-29, 02:08 AM
  4. Workset logs & server hard drive space
    By ToddVB in forum Revit - Worksharing/Worksets/Revit Server
    Replies: 4
    Last Post: 2006-01-04, 06:56 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •