Closed
Description
Description
When executing a python script by double clicking it, it is executed in %windir%\System32 instead of the current directory. I checked and the scripts aren't run as admin so that can't be the problem.
A workaround would be to open the current folder in cmd and excecute the script with "python script.py" or to directly type "python script.py" in the address bar
Steps To Reproduce
- execute the following python script by double clicking it. it prints out the current working directory and if the script is executed with admin privileges:
import os
import ctypes
def is_admin():
try:
return ctypes.windll.shell32.IsUserAnAdmin()
except:
return False
# Print the current working directory
print("Current working directory: ", os.getcwd())
# Check for admin permissions
if is_admin():
print("The script is run with administrator permissions.")
else:
print("The script is not run with administrator permissions.")
# Prevent the script from automatically exiting
input("Press Enter to exit...")
- in Windows Explorer I get the following output:
Current working directory: C:\test
The script is not run with administrator permissions.
- in Files I get the following output:
Current working directory: C:\WINDOWS\system32
The script is not run with administrator permissions.
Requirements
- Fix Python scripts not being executed in the current working directory
Files Version
3.1.1.0
Windows Version
10.0.23612.1000
Log File
nothing there