General Consultant Discussion

 View Only
  • 1.  How best to run a batch file in windows task scheduler without requiring a user to be logged in?

    Posted 02-10-2021 13:44
    Issue: 

    Windows Task Scheduler won't allow you to run a scheduled task that executes to the desktop unless the user assigned to run it is also logged in.  I have encountered this with BAT files that were created and added to Task Scheduler. Everyone runs beautifully so long as the user that created them leaves their session on the server open.

    If that user logs out I'm faced with a fail message that the process didn't run because the user wasn't logged in.

    In some cases, I can re-write the BAT file and add the task directly to the task scheduler in a way that doesn't require a login.
    However, there are some tasks - like a VI BAT file to run a VI Job automatically which I don't think I can easily rewrite to not use the Windows desktop.

    I'm told that maybe Powershell could do this. In other cases, I think I've seen a utility used to automatically log a Windows User in should the server reboot. 

    Is there something that I'm overlooking that I could be doing to work around this limitation of BAT file with the task scheduler?

    PS - Is there any utility which could send an email nightly to advise of which tasks executed without error and which ones produced an error?

    ------------------------------
    Wayne Schulz - Schulz Consulting - 860-516-8990
    ------------------------------


  • 2.  RE: How best to run a batch file in windows task scheduler without requiring a user to be logged in?

    Posted 02-10-2021 17:14
    @Marc Cregan? He recently created a BAT file for one of our customers for their VI jobs and I don't believe they have to be logged in. I think he created a user just for it though. Marc, can you expand/verify??​

    ------------------------------
    Therese Logeais, Technology Integrators
    ------------------------------



  • 3.  RE: How best to run a batch file in windows task scheduler without requiring a user to be logged in?

    Posted 02-10-2021 18:43
    Have you tried using the Sage batch scheduler for this?  From my experience with the Sage scheduler (v2018), Sage would not drop the user once the job ran.  I gave up on it at that point.  Last week, client IT called because I wanted them to stop the CS OBDC drive every night.  They wanted the user login / PW running the service.  But I don't think this is the same as what you need.

    ------------------------------
    Jeff Schwenk
    FORMER 90M Board Member
    Bottomline Software, Inc.
    Waynesboro VA
    540-221-4444
    ------------------------------



  • 4.  RE: How best to run a batch file in windows task scheduler without requiring a user to be logged in?

    Posted 02-11-2021 01:36
    For VI Jobs or anything triggered by Sage, or similar things (like ROI Manager), we typically run those inside an auto-logon account. Some policies would need to be set on it so that it doesn't timeout/disconnect, etc... all tasks run fine inside it. I realize that it doesn't answer your direct question per se, but it works. 

    In my experience, anything that spawns any kind of process that requires an interactive desktop is going to be difficult to run via task scheduler when no user is logged in.

    ------------------------------
    George Khairallah
    CTO | gotomyerp, LLC
    george.k@gotomyerp.com | 877-888-5525
    http://gotomyerp.com/
    ------------------------------



  • 5.  RE: How best to run a batch file in windows task scheduler without requiring a user to be logged in?

    Posted 02-11-2021 01:54
    I do a lot of batch files on Task Scheduler that run without the user logged in. The times that I've had problems were when if I forgot and used a mapped drive instead of local drive or a UNC for a resource.

    ------------------------------
    Dan Burleson
    Software Consultant
    Connex Software
    Corvallis OR
    541-224-6642
    ------------------------------



  • 6.  RE: How best to run a batch file in windows task scheduler without requiring a user to be logged in?

    Posted 02-11-2021 09:24
    Wayne,

    Though I don't know of any utility outside of Sage 100  if the task was executed, I've written some PERFORM script that will send an email with an attachment after the job is done.  I do have a proposal with a client that wants to send an email at the beginning and at the end of the V/I job to ensure that it started.  They have quite a few that are on a scheduled task.  They haven't approved it yet.

    ------------------------------
    Marcos DeLuna
    Deluna Consulting
    ------------------------------



  • 7.  RE: How best to run a batch file in windows task scheduler without requiring a user to be logged in?

    Posted 02-11-2021 09:47
    Thanks, everyone. This is all helpful.

    For clarification - if I manually run a task at Windows Task Scheduler while I am logged onto the server and see it execute on the server desktop ( a window pops up, etc ) then I find that task has to run while the user account is logged in. 

    In one instance I have inherited a batch file that runs a Crystal Report and since that is appearing on the desktop I will get an error message in the Windows Task Scheduler unless I leave my session open and running.

    I think the fastest workaround is: 

    a. Create a new Windows account that is not used by anyone to regularly login ( this helps avoid inadvertently logging out during daily use )
    b, Use Autologon ( which I have used in the past for customers who had problems running Sage 100 Advanced as a service



    ------------------------------
    Wayne Schulz - Schulz Consulting - 860-516-8990
    ------------------------------



  • 8.  RE: How best to run a batch file in windows task scheduler without requiring a user to be logged in?

    Posted 02-11-2021 10:06
    VI doesn't require a disconnected session.  If a batch file doesn't work without one, the command line is not correct.  We use scheduled VI jobs in many many places, and they all work without an open session.

    For programs that do need a disconnected session (ScanForce import, InSynch...), we have the customer / their IT maintain that on the Sage server (beyond the reach of users).

    ------------------------------
    Kevin Moyes
    Technical Systems Analyst
    Munjal White Consulting Co.
    Toronto ON
    ------------------------------



  • 9.  RE: How best to run a batch file in windows task scheduler without requiring a user to be logged in?

    Posted 02-11-2021 10:31
    I think you are on the correct path Wayne.  We have lots of scheduled tasks which run to keep services which seem to fail intermittently running.  We setup unique users for each one for security reasons.  There is an option when you configure the task to Run whether user is logged on or not which is used as that account has limited login privilege's as well.

    ------------------------------
    Gary Feldman
    President
    I-Business Network, LLC
    Marietta GA
    6786270646 x224
    http://www.i-bn.com/
    ------------------------------