finally succeed with

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

robocopy C:\Users\administrator.domain\Documents\configswitchesSSH\%FOLDERNAME% \\\Config\autobackupexceptbalair\%FOLDERNAME% /E
robocopy C:\Users\administrator.domain\Documents\configswitchesTelnet\%FOLDERNAME% \\\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

@echo off

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

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

import shutil, errno
import time
import os

def copyanything(src, dst):
        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")

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


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

  • 1
    The answer you are looking for likely lies within here though so read thru.... superuser.com/questions/1005192/… Almost all of this applies to Windows 10 still too but I know you say you are using Windows 7. – Pimp Juice IT Sep 11 '17 at 5:30
  • Really thanks, succeed to run but it need domain administrator to login local desktop , normal user can not run even if policy grant right and use as administrator – user45543 Sep 12 '17 at 16:28
  • So are you saying you were able to resolve or confirm the issue per the "LOG ON AS A BATCH JOB PERMISSIONS" portion form my referenced answer on the other post? – Pimp Juice IT Sep 12 '17 at 16:31
  • Yes, but I meet another problem that python script access denied when create folder and copy files to share folder though using domain administrator – user45543 Sep 13 '17 at 16:56
  • Update your question with an edit and show everything you are using as in 1. here's the batch script and correlated logic 2. here's the python script logic 3. here's how Task Scheduler is setup to execute it the task 4. here's the exact error when it's executed.... Show me everything and I may be able to assist further. – Pimp Juice IT Sep 13 '17 at 17:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.