Scheduled Task Windows Server 2008 R2 hung in "running" state, status (0x41301)

Hi

I am trying to get a scheduled task to run on a schedule on Windows Server 2008 R2 OS and it keeps hanging in the "running" state without ever completing. The task calls a batch file in command prompt to connect to a remote server using psftp.

This batch file runs fine when it is executed manually under the user credentials,but for some reason it never completes when added to a scheduled task.

In the "Last Run Result" field there is a status of (0x41301)
This task has been set up with the following details from each tab:

General Tab:
set up to run with a domain account with local admin permissions on the server
set to run whether or not a user is logged on
Do not store password is not checked
Run with highest privileges is checked

Triggers Tab:
Set to run Monday, Tuesday, Wednesday, Thursday, Friday of each week

Actions Tab:
Start a program located on the D: drive ( a windows bat file that calls psftp) psftp.exe file is located in the same directory on the D: drive as the bat file
The fields "Add arguments" and "Start in" are blank

Conditions Tab:
Power - Start the task only if computer is on AC power - checked
Stop if computer switches to battery power - checked

Settings Tab:
Allow task to be run on demand - checked
Stop the task if it runs for longer than 3 days
If the running task does not end when requested force it to stop - checked

The domain account that the task runs under has full control (is a local admin on server) of the drive and folders containing the exes and bat files so it shouldn't be a permissions issue either. The log for the task only tells me the task commenced but no more information is provided.
itwexAsked:
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.

vin_shooterCommented:
Hi,

1.    Make sure the account to run task scheduler is in group "log on as batch job" rights (on server side). Control Panel\|Admin Tools\Local Security Policy\Local Policies\User Rights Assignments\Log on as a batch job
 
 
2.    Check if the script runs under a path where the logon domain user has the proper permission.  If not, you may add a path like "c:\users\%username%\desktop" into the Scheduled Task start in properties.


http://social.technet.microsoft.com/Forums/en-US/winservergen/thread/933aac93-d972-4aea-adeb-1fc1fba6a4c4

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Haresh NikumbhSr. Tech leadCommented:
can you export task in xml and attached here.
itwexAuthor Commented:
Hi,
thanks for the suggestions, I have added the account to the Log on as a batch job role and that didn't fix the issue; I still had the same "running" state on the task.

I have since added the path C:\users\%username\desktop into start in and that didn't resolve it either. I copied all of the directories containing the task files onto the C:\users\%username%\desktop but it didn't run properly following this either.

The account running the task is a local administrator on the server. I have now also added the account explicitly to the ACL on the folder containing the exes and bat files but the task hung while "running" again.

I have logged on to the server as the domain user set to run the task and that won't run either. No information in the task history unfortunately...
Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

vin_shooterCommented:
Login to the remote server in which the task initiates psftp.exe, check for session in that server by executing quser command for the USED ID configured in the scheduled task.

If it exists kill the session and run the task again.

Check for any error if it fails

share the results..,
itwexAuthor Commented:
Hi
I manually executed the task again and psftp.exe*32 is showing in process list, the task is listed as running.
When I execute quser <username> it just responds with "No user exists for <username>"
The psftp.exe process is still executing and using 1,288k of memory;but task is in state running and status is (0x41301)
itwexAuthor Commented:
All aspects covered by solution, the problem appeared to be the fact that start in path was not correctly populated. Also the exe file was copied into the path where the task runs the batch as suggested. Thanks for the help
yuschangCommented:
hi itwex,

may i know how did u resolve the issue as i also facing the same issue with the windows 2012 server. The task scheduler shows running but nothing happens.
itwexAuthor Commented:
Hi yuschang, I resolved the issue by a process of elimination:

I had to specify the D:\..\ folder in start-in path - this was where all related files to the task are stored.

I also had to copy the exe file into the directory too, the task seemed to have an issue with running files outside of the start-in path.
yuschangCommented:
HI itwex,

Many thanks for your reply.

I had specify the folder path in start-path since beginning but it was just the same.

What do u mean by "copy the exe file into the directory"

Is it copy the batch script into C:\ ?

Thanks
itwexAuthor Commented:
Hi Yuschang
The batch file was calling an exe, so all I did was copy the batch file and the exe it was calling into the same directory, the server had a few partitions, in this instance I was running from a D: partition

I made sure the permissions were ok on this directory for the user running the task (test this, log on as the user to server and try executing the batch file)
Hope this helps
yuschangCommented:
Hi itwex,

I have just resolved the issue by logging in to the server with the user id and disconnect it without logging out.

Thanks for your kind help
itwexAuthor Commented:
Hi yuschang, glad you got your issue resolved
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
Microsoft Legacy OS

From novice to tech pro — start learning today.