tmwoods tmwoods - 3 months ago 11
Git Question

Running bat file with scheduled task and failing with 'There are no child processes to wait for'

I'm running a

bat
file from
Task Scheduler
and am getting a last run result of
There are no child processes to wait for. (0x80070080).
without the intended result of the script. If I run the script manually it works like a charm. It is just doing an automated
git
commit
and
push
. Any searching I do on the error proves to be a bit useless.
Anyone have any insight for me?

The
bat
file contains the following:

@echo off
For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set mydate=%%c-%%a-%%b)
For /f "tokens=1-2 delims=/:" %%a in ('time /t') do (set mytime=%%a%%b)
Set hname=%COMPUTERNAME%
cd %HOME%\my_dir
git config --global user.name "Batch Script"
git config --global user.email "bat@test.com"
git add --all
git commit -m "File Backup: %mydate%_%mytime%_%hname%"
git push 2>&1
EXIT


Things I have tried:


  • running as .bat or .cmd (recommended here)

  • changing program/script to be 'cmd.exe' and arguments to be /c "C:\mypath\myscript.bat" (recommended here)

  • changing program/script to be 'test.bat' and 'Start in' to be "C:\mypath" (recommended here)

  • running as
    SYSTEM



All of these result in the same error message as listed above.


  • Adding
    | Out-Null
    after
    2>&1
    results in the error message now being
    The extended attributes are inconsistent


Answer

A coworker figured it out!

The HOME variable actually isn't defined when you are logged out. So once I explicitly defined the HOME variable in my script, things worked perfectly.

The Fix:

I added $env:HOME = "C:\myHomePath" before the git commands.