i try this script to run robocopy command and copy the user desktop to shared folder on network
the problem is robocopy shoud run as administrator so when i run it message show to enter administrator password
import os
import smtplib
import getpass
import subprocess
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.base import MIMEBase
from email import encoders
#get user name
usrnm = getpass.getuser()
#create folder on network
file_path= "\\\\10.0.0.181\\companyfiles"
dirctory_path =file_path+"\\"+usrnm
#check if dirctory does not exist
if not os.path.exists(dirctory_path):
os.makedirs(dirctory_path)
#Deskktop Start
source1 = "C:\\users\\" + usrnm + "\\Desktop\\ "
dest1 = dirctory_path + "\\Desktop\\ "
cmd1 = "robocopy " +source1 + dest1 +" /E /XA:H /W:0 /R:1 /REG /FFT /E >> C:\\"+usrnm+"desktopbackup.log"
subprocess.call(['runas', '/user:Administrator', cmd1 ])
#os.system(cmd1)
print (cmd1)
print("doen")
#os.system(cmd1)
#desktopEnd
#send email with log
so can you fix it or can you make script to differential backup for desktop , documents with sending email with log file
Thanks