Avatar of Christian Palacios
Christian Palacios
Flag for Canada asked on

Batch file in Scheduled Task completes only when user is logged onto server

Hi there,

I have a scheduled task with these properties:

User account to run the task: A Service account that has logon as batch file privileges
Run whether user is logged on or not is enabled
Run with highest privileges is enabled
Configured for Windows Server 2012 R2
Trigger: Runs hourly
Actions values:
  • Action: Start a program
  • Program/script: Powershell.exe
  • Arguments: -command "Start-Process  C:\Build.bat -Verb runas"
  • Start in: C:\SDS_IT\

Now the problem I am having is that even though I have set the task to run whether user is logged on or not, it never completes unless the user is actually logged on.  If it I log out, the task starts and it gets to about 95% done and then it just gets stuck.  I've tested this theory several times and this is always the case.  I'm confused as to why it's not working.  The service account has local administrative permissions on this VM too.  I'm using PoweShell because I want the script to run a command prompt as administrator.

Any thoughts????
Thank you in advance!
-Christian
Windows Batch* task schedulerWindows Server 2012

Avatar of undefined
Last Comment
Qlemo

8/22/2022 - Mon
SOLUTION
Gerwin Jansen

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER CERTIFIED SOLUTION
Steve Knight

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Christian Palacios

ASKER
Hi there,

Thanks for the suggestion Steve, I didn't think about using an output file to see what's happening.  It's working for the sections that I need to troubleshoot.  Does anyone have experience with using Git?  If not, that's OK, I'll create a new question.
Gerwin Jansen

>>  Does anyone have experience with using Git?
So it's a git command that is hanging / causing the issue?

Can you add a 'fake' command in the batch file:

git --version >> log.txt

Do you get an error? Then try adding setting the git environment variables in your script and add it to the PATH.
Qlemo

Git commands might need a -f (force) or -y (answer "Yes") switch to remove prompting.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck