#๐Ÿ”’ Secure Boot Checking on Python

5 messages ยท Page 1 of 1 (latest)

acoustic spindle
#

Hello I've tried to find out whether secure boot is enabled here is the code of what I tried:

def is_secure_boot_enabled():
try:
    # PowerShell command to check Secure Boot status
    ps_command = 'Confirm-SecureBootUEFI'
    
    # Execute the PowerShell command
    result = subprocess.run(['powershell', '-Command', ps_command], capture_output=True, text=True)
    
    # Process the result
    if "True" in result.stdout:
        return True
    elif "False" in result.stdout:
        return False
    else:
        print(f"Unexpected output: {result.stdout}")
        return None
except Exception as e:
    print(f"Error: {e}")
    return None

This requires Admin / Elevated Permissions to run, so I was unable to run this command

I've also tried another script:

https://www.hindicodingcommunity.com/2023/02/how-to-check-whether-secure-boot-is.html

which also had an issue :

Error: (-2147217392, 'OLE error 0x80041010', None, None) None

Let me know if theres another way to find out.

HindiCodingCommunity

How to check whether secure boot is enabled using python in windows os

tidal compassBOT
#

@acoustic spindle

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

open elbow
#

you'll have to run your script with elevated permissions

tidal compassBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.