2

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
Community
  • 1
  • 1
tmwoods
  • 2,149
  • 7
  • 24
  • 52
  • Read this about the difference between bat and cmd http://stackoverflow.com/questions/148968/windows-batch-files-bat-vs-cmd – Randy Schuman Aug 26 '16 at 01:36
  • Task Scheduler bat vs cmd http://stackoverflow.com/questions/19304652/run-a-batch-file-from-task-scheduler-is-not-working-with-a-java-command – Randy Schuman Aug 26 '16 at 02:37
  • @RandySchuman, how is the BAT-vs.-CMD topic related to this question? would you mind to explain, please? – aschipfl Aug 26 '16 at 09:04
  • It matters if you have a .bat extension.I assume that you do since you reference bat. One of the articles states that running a .bat file manually is not the same as running it from Task Scheduler. There are differences. One of those being how errorlevels are handled. So in other words, try renaming it to .cmd to see what happens. – Randy Schuman Aug 26 '16 at 14:33
  • If you are running the task as "System", another thing you could check is if there are some environment variables that were set for your user profile, but not system (global). – Randy Schuman Aug 26 '16 at 15:02
  • I had actually already tested with `.bat` and `.cmd` but alas both have the same result. I've also double checked and I am running it as myself with highest privileges. – tmwoods Aug 26 '16 at 16:22
  • I am still trying to find an answer for you. I can find similar programs with the same message where people had success with by using "call" or "start /wait" in the batch file. One git user had a forking problem and wrote the batch file in Bash and that fixed it. They just released a new version 2 days ago. Worth a shot. "Git's .exe files are now code-signed, helping with performance when being run with Windows File Protection." – Randy Schuman Aug 27 '16 at 09:41
  • @RandySchuman Awesome, I will definitely look into this when I get in on Monday :) Thanks a lot for the effort! – tmwoods Aug 27 '16 at 20:18
  • No luck with `START /WAIT`. Looking into running bash scripts but looks like I'll need some extra software (I'm using `Server 2012`) – tmwoods Aug 29 '16 at 22:09

1 Answers1

1

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.

tmwoods
  • 2,149
  • 7
  • 24
  • 52