fbt.ps1 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. Push-Location $PSScriptRoot
  2. $firmware_path = ""
  3. $firmware_name = ""
  4. if (('official', 'off', 'o').Contains($args[0])) {
  5. $firmware_path = "flipperzero-firmware_official"
  6. $firmware_name = "Official"
  7. }
  8. elseif (('unleashed', 'un', 'u').Contains($args[0])) {
  9. $firmware_path = "flipperzero-firmware_unleashed"
  10. $firmware_name = "Unleashed"
  11. }
  12. else {
  13. throw "Unable to recognize which firmware to use"
  14. }
  15. Write-Host "Using $firmware_name firmware to run FBT"
  16. if ((Test-Path -Path "$firmware_path\applications_user\totp") -ne $True) {
  17. $mklink_command = "mklink /D $firmware_path\applications_user\totp ..\..\totp"
  18. if (!(New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
  19. Start-Process -FilePath 'cmd' -ArgumentList ( "/C", "cd $PSScriptRoot & $mklink_command") -Verb RunAs
  20. } else {
  21. Invoke-Expression -Command $mklink_command
  22. }
  23. }
  24. $builtin_totp_path = "$firmware_path\applications\plugins\totp"
  25. if ((Test-Path -Path $builtin_totp_path) -eq $True) {
  26. Remove-Item $builtin_totp_path -Recurse
  27. }
  28. Push-Location $firmware_path
  29. ./fbt $args[1..($args.Length - 1)]
  30. Pop-Location
  31. Pop-Location