I have created a python 3.4 script to delete files in a foler(Temp files o fWindows Folder)
Here it is but it is not working
import os, subprocess
del_dir = r'C:\Users\vaibhav2\AppData\Local\Temp'
pObj = subprocess.Popen('del /S /Q /F %s\\*.*' % del_dir, shell=True,
stdout = subprocess.PIPE, stderr= subprocess.PIPE)
rTup = pObj.communicate()
rCod = pObj.returncode
if rCod == 0:
print ('Success: Cleaned Windows Temp Folder')
else:
print('Fail: Unable to Clean Windows Temp Folder')
EDIT
Some of the code has been edited The error I am facing is that it deletes only some files instead of ALL files in %tmp% folder of Windows ,even if I run the script as Admin. If it requires authentication please provide the code for providing password to this command of admin because I can't do right click run as admin every time
Thanks in advance