Skip to content

Commit ba6c2df

Browse files
committed
Merge pull request opencv#14229 from alalek:ffmpeg_downloader_elevated_run
2 parents c300070 + 97548b0 commit ba6c2df

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

3rdparty/ffmpeg/ffmpeg-download.ps1.in

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,22 @@ Write-Output ("=" * 120)
1212
Write-Output ""
1313

1414
if(![System.IO.File]::Exists($output)) {
15+
try {
16+
[io.file]::OpenWrite($output).close()
17+
} catch {
18+
Write-Warning "Unable to write: $output"
19+
if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
20+
Write-Warning "Launching with 'Administrator' elevated privileges..."
21+
Pause
22+
Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs
23+
exit
24+
} else {
25+
Write-Output "FATAL: Unable to write with elevated privileges: $output"
26+
Pause
27+
exit 1
28+
}
29+
}
30+
1531
try {
1632
Write-Output ("Downloading: " + $output)
1733
Import-Module BitsTransfer

0 commit comments

Comments
 (0)