When I run a executor file which built with pyinstaller with Administrator priviledge

it shows “[WinError 5]” which I don`t have the priviledge. it is same error when I rewirte the code in a “Thread” way.
but it is ok when I rewrite the code in the normal way which is one thread in one process?
so ,can you guys help me to fix it ?

Not without significantly more information about the error and what you’re trying to do.

If you share the full error message, including traceback, as well as any source code that is referenced by the error, somebody might be able to help.

1 Like

sorry,this executor is being used to search the whole windows registry and delete what it finds, this action needs administrator priviledge usually,but it runs so slow, it took me 160 s to search the whole reg…I want to run this tool faster in windows 10-1809,so here came the problem.


dont mind the "注册表键已删除"tips ,it did not delete the reg,
it should exit after throwing the error “请右键以管理权限运行!” which means run this exe after you click the right mouse button with administrator priviledge, but I won’t let it go now so that we can see the error, it ran the exe with administrator priviledge already

sorry guys. my mistake
winreg or win32api does not have the ability to delete the key with subkeys
case closed

wonder when they will add the ability :pensive:

Use win32api.RegDeleteTree(), which wraps WinAPI RegDeleteTreeW(). The hKey handle should be opened with KEY_ENUMERATE_SUB_KEYS, KEY_QUERY_VALUE, and KEY_SET_VALUE access. The documentation claims that hKey needs to also be opened with DELETE access, but this function never deletes the key that’s referenced by hKey. I tested without DELETE access, and it worked fine.

Python’s standard library should probably be updated to support this registry function as winreg.DeleteTree().

thanks a lot