2

update3a

finally succeed with

set buildDate=%DATE:~4,10%
set dateStr=%buildDate:~3,2%-%buildDate:~0,2%-%buildDate:~6,4%
set FOLDERNAME=configswitches%dateStr%
echo %FOLDERNAME%

robocopy C:\Users\administrator.domain\Documents\configswitchesSSH\%FOLDERNAME% \\192.168.187.2\Config\autobackupexceptbalair\%FOLDERNAME% /E
robocopy C:\Users\administrator.domain\Documents\configswitchesTelnet\%FOLDERNAME% \\192.168.187.2\Config\balairconfig\%FOLDERNAME% /E

update 3

not resolved yet, it need to manually run in cmd, Task scheduler ran with last result (0x1) and has history task completed, but manually click to run in task scheduler and time trigger can not create folder and copy file to share folder

runcopy.bat
@echo off

Powershell -noprofile -executionpolicy bypass -file "C:\Users\administrator.domain\Documents\runcopy2.ps1"

runcopy2.ps1
python C:\Users\administrator.domain\Documents\copyfiles.py


import shutil, errno
import time
import os

def copyanything(src, dst):
    try:
        shutil.copytree(src, dst)
    except OSError as exc: # python >2.5
        if exc.errno == errno.ENOTDIR:
            shutil.copy(src, dst)
        else: raise


foldername = "configswitches" + time.strftime("%d") +"-" + time.strftime("%m") + "-" + time.strftime("%Y")

#print(os.path.join("C:\\Users\\administrator.domain\\Documents\\configswitchesSSH",foldername))
copyanything(os.path.join("C:\\Users\\administrator.domain\\Documents\\configswitchesSSH\\",foldername),os.path.join("Y:\\autobackupexceptbalair\\",foldername))
copyanything(os.path.join("C:\\Users\\administrator.domain\\Documents\\configswitchesTelnet\\", foldername),os.path.join("Y:\\balairconfig\\",foldername))

update Meet another problem, Access is denied when using os , to create folder and copy files to share folder of domain controller with administrator

Then I discover normal user account create folder in this share folder, domain administrator can not create folder in it and even delete this folder, it is like orphan folder and I switch user back to normal user account to delete this folder and hope to use domain administrator to create folder in share folder but when I login domain controller with domain administrator to create folder in share folder , it has denied access too. I am asking my supervisor to use another super user account to create this share folder and hope this can let python script to create folder with domain administrator

previous update

After change to use domain administrator in local desktop and create task and configure log batch this group policy , the task scheduler can run python script with batch file.

when run batch file of normal user got error Error Value: 2147942667

C:\Users\hello\Documents\configswitchesSSH\runschedule.bat

Start in (Optional) C:\Users\hello\Documents\configswitchesSSH

there is no quota for path still have error in window 7

originally, this task is created in user hello , normal user account, owner and run whether user log in or not

but normal user account can not run batch file

then i change to use domain administrator account by click change user

however click run to test, it has errorĀ 2147942667

when i remove path in start in (optional), keep it empty, then run it , it can not run the batch file without any error message or pop up, because the batch file will run python a.py this command, this program will create directory and generate file, but no files and no directory created after click run in task scheduler

0 Answers0