I am trying to obtain the total disk capacity and the amount of free disk space on a Windows 10 machine. I don’t see any Julia command that will do this so I thought that a Windows command would give me the required information.
julia> a = `Cmd /c dir`
`Cmd /c dir`
julia> b = readchomp(a)
" Volume in drive C is OS\r\n Volume Serial Number is 7825-EBFA\r\n\r\n Directory of C:\\Users\\jakez\\.julia\\dev\\Gantner\r\n\r\n2021-04-29 04:50 PM <DIR> .\r\n2021-04-29 04:50 PM <DIR> ..\r\n2021-04-12 06:33 PM <DIR> .vscode\r\n2021-04-12 06:24 PM <DIR> docs\r\n2021-04-20 04:03 PM <DIR> example\r\n2021-04-29 04:51 PM
1,088 LICENSE\r\n2021-05-12 11:34 AM 281 Manifest.toml\r\n2021-05-12 11:34 AM 179 Project.toml\r\n2021-04-29 04:57 PM 347 README.md\r\n2021-05-17 03:10 PM <DIR> src\r\n2021-05-12 11:22 AM <DIR> test\r\n 4 File(s) 1,895 bytes\r\n 7 Dir(s) 133,166,219,264 bytes free"
julia>
I am sure I can figure out a way to obtain the free disk space from this. However the Windows command
julia> a = `fsutil volume diskFree C:`
`fsutil volume diskFree C:`
julia> b = readchomp(a)
"Total free bytes : 133,171,417,088 (124.0 GB)\r\nTotal bytes : 510,208,765,952 (475.2 GB)\r\nTotal quota free bytes : 133,171,417,088 (124.0 GB)"
julia> typeof(b)
SubString{String}
gives both the free disk space but also the total disk size. However it needs administrative privileges to execute. In this case I right clicked on Julia to run with administrative privileges. How can I get this to run without running Julia with elevated privileges?
Or is there a better way?