My problem is, imagine I need to make a python script which will create a text file in the user's C: drive when he runs the script.
The code I have used is,
import os
import getpass
#taking the username
uName = getpass.getuser()
#defining the file path and name
pathPy = "C:/Users/"+uName+"/death.txt"
#creating the .txt file in the said path
file1 = open(pathPy, 'w')
file1.write("Hellow Death")
file1.close()
This works on my PC as I am the admin. But when I tried running this on a VirtualBox, it gave an error 'Permission Denied'.
Can this be solved by making an .exe from this script which would request permission at the beginning? If so, please guide me through it!! I'm no pro at python so I would be grateful if someone could explain what happens along with the code. :)
Thank you in advance. <3
Update: I made an .exe of the python script and when run as the Admin, it does the job. But if I just double click on it, it does not work because I don't know how to make the script require admin privilege when trying to install. If someone can shred some light on it, that would be amazing! :)