How to request UAC in fsi and fsharp script
I have a script:
open System
open System.IO
let fileSize path =
try
Some((new FileInfo(path)).Length)
with
| e ->
printfn "%A" e
None
let dirSize dir =
Directory.GetFiles(dir,"*",SearchOption.AllDirectories)
|> Array.map fileSize
|> Array.map (Option.defaultValue 0L)
|> Array.reduce (+)
dirSize """C:\Users\xxx\Documents""";;
I run it System.UnauthorizedAccessException
.
I'm trying to run cmd
or fsi
as administrator, but either worked.
I find a solution used in fsharp program using Manifest file
.
But the parameter --win32manifest
cannot be used in fsi (this is an option fsc
). error FS0243: Unrecognized option: '--win32manifest'
...
Is there any solution for asking UAC in a script?
(I know how to fix the script above by replacing the method GetFiles
to catch the exception)
source to share
I can say that after a little research that is not a .FSX issue, I was able to replicate the issue in visual studio in C # and in F # apps. Here is a link on a similar issue. I think the solution would be to use a folder where you have full permissions (something in my docs has an iffy), or use a solution like this as a starting point.
source to share