RaptorRV
RaptorRV

Reputation: 65

Opening Microsoft store apps with Python

I am trying to open a Microsoft store app with python code it is like this:

import subprocess
subprocess.Popen("C:\Program Files\WindowsApps\Microsoft.MinecraftUWP_1.16.2.0_x64__8wekyb3d8bbwe\Minecraft.Windows.exe")

       
    

when I run this it gives me this error

[WinError 5] Access is denied

is there any way to fix this?

Upvotes: 0

Views: 824

Answers (1)

chasedig
chasedig

Reputation: 58

This is because the executing privileges of your file are lower. To combat this, try right clicking your file and clicking "Run as Administrator". This will allow it to do things that require higher system permissions.

Hope I helped!

I found this code here: Request UAC elevation from within a Python script?

import ctypes, sys

def is_admin():
    try:
        return ctypes.windll.shell32.IsUserAnAdmin()
    except:
        return False

if is_admin():
    # Code of your program here
else:
    # Re-run the program with admin rights
    ctypes.windll.shell32.ShellExecuteW(None, "runas", sys.executable, " ".join(sys.argv), None, 1)

Put this into your code and you should be able to open a Win10 Store Application via Python.

Upvotes: 1

Related Questions