Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.

Windows 7: Command Line - Help

12 Sep 2014   #11

Windows 7 32 bit

Here's the source to df if you want to adapt it. The WinApiEx include file has all the API calls you need. It's included with AutoIt3 download package I believe.
On second thought I get compile errors. Constants already defined. So best to stick to vbscript? Hehe.

My System SpecsSystem Spec
12 Sep 2014   #12

Windows 7 32 bit

OK. I had a munged install of AutoIt3 that gave errors. I uninstalled it and installed the latest stable version and the Scite4AutoIt3 editor. These are free tools. Both may be downloaded here:

I compiled and ran this source successfully on both a Windows 7 x64 VM and on native Windows 8.0 x64. No errors or warnings.

Here's the source

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Res_Description=Disk Free Space
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <WinAPIEx.au3>
Opt('MustDeclareVars', 1)
Global $GB = 1024 * 1024 * 1024
Global $MB = 1024 * 1024
Global $KB = 1024
Global $div, $whole, $frac, $unit, $result, $drive, $len

If Not $CmdLine[0] Then
    $drive = StringLeft(@WorkingDir, 2)
ElseIf $CmdLine[1] = "/?" Then
    For $x = 1 To $CmdLine[0]
        If StringLen($CmdLine[$x]) = 1 Then
            $drive = $CmdLine[$x] & ":"
            $drive = $CmdLine[$x]

Func DisplaySpace()
    Local $Data = _WinAPI_GetDiskFreeSpaceEx($drive)
    If @error Then
        ConsoleWriteError("Error detecting free disk space on " & $drive & @CRLF)
    If $Data[2] >= $GB Then
        $div = $GB
        $unit = "GB"
    ElseIf $Data[2] >= $MB Then
        $div = $MB
        $unit = "MB"
    ElseIf $Data[2] >= $KB Then
        $div = $KB
        $unit = "KB"
        $div = 1
        $unit = "B "
    If $div = 1 Then
        $result = String($Data[2])
        $result = StringFormat("%.5f", $Data[2] / $div)
        If StringRight($result, 6) = ".00000" Then
            $result = StringLeft($result, StringInStr($result, ".") - 1)
            $result = StringLeft($result, StringInStr($result, ".") + 3)
    $result = StringFormat("%-9s", $result)
    $result &= $unit & " Free on "
    ConsoleWrite($result & $drive & @CRLF)
    If Not $CmdLine[0] Then
        ConsoleWrite(@TAB & "( df /? for help )" & @CRLF)
EndFunc   ;==>DisplaySpace

Func ShowHelp()
    Local $ver = FileGetVersion(@ScriptFullPath)
    If $ver = "" Then
        $ver = ""
    ConsoleWrite(@CRLF & @ScriptName & " " & $ver & " Copyright " & @YEAR & "" & @CRLF)
    ConsoleWrite(@CRLF & "Usage: df [ C D \\Name\Share ]" & @CRLF & "free disk space in one of B KB MB GB" & @CRLF)
    ConsoleWrite(@CRLF & "( Truncated to 3 decimal places. )" & @CRLF & @CRLF)
EndFunc   ;==>ShowHelp
My System SpecsSystem Spec

 Command Line - Help

Thread Tools

Similar help and support threads
Thread Forum
Command line - Some questions
I've created a batch file for zipping selected items in a folder. (The file is placed in 'Send to'). If I use the following code: for %%* in (.) do set CurrentFolder=%%~n* "C:\Program Files\WinRar\WinRar" a -afzip "%CurrentFolder%.xpi" The file name is that of the current folder...
General Discussion
What is wrong with this command line?
Help please I am pulling my hair out. I use a desktop shortcut to run an application called get_iplayer.cmd located in the directory c:\program files\get_iplayer The line in the Target of the shortcut properties therefore reads: C:\Windows\System32\cmd.exe /k "c:\program...
General Discussion
How can I set this via command-line or registry?
How can I set this via command-line or registry? I need a way to automatically launch "Explorer c:\folder\myfolder" with a view appropriate for long filenames on any Windows Vista/Win7 PC.
Gpedit via command line
how can I enable disable a policy using gpedit! Not via the GUI, you go do some clicks and enable. But I want to execute one shot command which will say disable AutoRun. I have searched exenstively, no results. I kind need this for my automation stuff. Thanks, Akshay
Performance & Maintenance
How to run a command line utility?
Hi, I am trying to run a command line prompt utility from Microsoft on windows 7. Sure I am doing something wrong, after I click the downloaded .exe file the command prompt pops up briefly then disappears. Can someone explain the basics of running a command line utility on win7? Thanks! ...
General Discussion
Command Line
Is there a cmd.exe /switch for “run as administrator” ? Thanks-
General Discussion

Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd

All times are GMT -5. The time now is 14:27.
Twitter Facebook Google+ Seven Forums iOS App Seven Forums Android App