E_J E_J - 1 year ago 654
Python Question

subprocess permission denied

I was looking into how python can start other programs on windows 10, I was on stack overflow and someone said that:

import subprocess
subprocess.call(['C:\\Users\Edvin\Desktop', 'C:\\Example.txt'])

should do it, so I changed the locations so it is specific to me and there was an error which was
PermissionError: [WinError 5] Access is denied

Does anyone know how to grant permission for python to open the file?

I've tried:

import subprocess
'\\Start Menu\\Programs\\Accessories\\Notepad.exe'],

but this comes up with
TypeError: bufsize must be an integer

Answer Source

The thing is that you're trying to launch your desktop as a program. With a text file as an argument.

This is not allowed because you're not allowed to execute the desktop (because it can't be executed).

subprocess.call(["command here", "arguments here"])

if it's an exe use

subprocess.call(['C:\\...\\program.exe', 'argument'])

if it's a python script use

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download