Git commands inside a batch file won't run under a scheduled task when no user is logged onto the server.

I have a scheduled task that runs a batch file.  The batch file has several lines where I do a "git pull" command from a specific Git repository.  The Windows server where this runs has already been configured with proxy settings so that when you run "git pull" or any "git" command, it will properly connect to the required repository and run the command.  I have figured out that this schedule task and batch file will run just fine when a user is logged on.  But if I log out of the server, the schedule task start, but the "git pull" command gets stuck.  It's almost like it's can't connect and then the rest of the batch file will not run.  What should I do to ensure the "git" commands run fine even when a user is not logged in?

Thanks in advance!
-Christian
Christian PalaciosSenior IT Systems AdministratorAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

aranaCommented:
When using that option you need to use also the "Run with highest privileges" option.

Also if your batch uses network shares , when not logged in it doesnt know which drives are mapped so it will fail.
aranaCommented:
Also check the user setup for running the task has all the proper permissions for any shares or internet access it might need.
Christian PalaciosSenior IT Systems AdministratorAuthor Commented:
Thanks Arana.  The scheduled task has "Run with highest privileges" enabled.  It's configured for Windows Server 2012 R2.  I am running this scheduled task with a service account, which by default, does not have a proxy account to go to the internet.  Here's what I do for each Git repository when I am doing a pull:

cd "C:\SDS_IT\OneGeo\configuration-manager"
git pull


Anything else I should try?
OWASP: Forgery and Phishing

Learn the techniques to avoid forgery and phishing attacks and the types of attacks an application or network may face.

aranaCommented:
try running it under an account that has proxy permissions, you can create one just for this purpose,
or try running
git config --global http.proxy http://proxyuser:proxypwd@proxy.server.com:port

Open in new window

Christian PalaciosSenior IT Systems AdministratorAuthor Commented:
Thanks Arana.  I have configured git with my proxy settings with the command you sent me.  I'll try it out and let you know.
Christian PalaciosSenior IT Systems AdministratorAuthor Commented:
Ok, that didn't work.  I made sure I could do a pull before I logged out after I set the global proxy settings.  I logged in to check it and it's still stuck at the first "git pull" command.  This is the command I ran:

git config --global http.proxy http://username:password@proxyIP:80

Anything else I could try?
aranaCommented:
hmm I would try to use an account other than that service (your for example) for running when not logged in, just to test if that is the issue then setup the actual account you will use in the proxy.
Christian PalaciosSenior IT Systems AdministratorAuthor Commented:
Just tried it by setting the scheduled task to run under my domain account.  I logged into the VM with my account and tested everything to ensure I was able to run every manually and everything worked.  I even ran the code I need to test with Visual Studio.  It still needs me to be logged into the VM before it'll do the "git" command.  Anything else I should try?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Version Control

From novice to tech pro — start learning today.