Jump to content
Sign in to follow this  
erifash

DriveGetInfo

Recommended Posts

Yeah, this program displays some info about the current drive it's in.

In order to do this I needed to get something that returned the current drive the script was in. I searched for some type of macro, but it doesn't exist! So, I made my own function:

Func _ScriptRoot()
  Local $sz_root = StringTrimRight(@ScriptDir, StringLen(@ScriptDir) - 3)
  If StringLen($sz_root) < 3 Then $sz_root = @ScriptDir & "\"
  Return $sz_root
EndFunc

...and here is the program:

#NoTrayIcon

$drv = _ScriptRoot()
$sys = DriveGetFileSystem($drv)
$lbl = DriveGetLabel($drv)
$ser = DriveGetSerial($drv)
$typ = DriveGetType($drv)
$freemb = Round(DriveSpaceFree($drv), 2)
$freekb = Int(DriveSpaceFree($drv) * 1024)
$freeby = Int(DriveSpaceFree($drv) * 1024 * 1024)
$totmb = Round(DriveSpaceTotal($drv), 2)
$totkb = Int(DriveSpaceTotal($drv) * 1024)
$totby = Int(DriveSpaceTotal($drv) * 1024 * 1024)
$sta = DriveStatus($drv)

$data = "Drive Analysis of:  " & $drv & @CRLF & @CRLF & "----------" & @CRLF & @CRLF & "File System:        " & $sys & @CRLF & @CRLF & "Label:            " & $lbl & @CRLF & @CRLF & "Serial:            " & $ser & @CRLF & @CRLF & "Type:             " & $typ & @CRLF & @CRLF & "Free Space:       MB " & $freemb & @CRLF & "                 KB " & $freekb & @CRLF & "                  Bytes " & $freeby & @CRLF & @CRLF & "Total Space:       MB " & $totmb & @CRLF & "                   KB " & $totkb & @CRLF & "                   Bytes " & $totby & @CRLF & @CRLF & "Status:          " & $sta
FileWrite("drive.log", $data)
Sleep(500)
Run(@SystemDir & "\notepad.exe " & @ScriptDir & "\drive.log", @SystemDir, @SW_MAXIMIZE)
Sleep(500)
FileDelete(@ScriptDir & "\drive.log")

Func _ScriptRoot()
  Local $sz_root = StringTrimRight(@ScriptDir, StringLen(@ScriptDir) - 3)
  If StringLen($sz_root) < 3 Then $sz_root = @ScriptDir & "\"
  Return $sz_root
EndFunc

It has one REALLY long line in it so please make sure to copy it exactly.

It would also be cool if _ScriptRoot was turned into a macro in the next version of AutoIt because it might be helpful to some people! :(

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...