Link to home
Start Free TrialLog in
Avatar of mrferrari
mrferrariFlag for United States of America

asked on

Scheduled Task only runs when user is logged in?

Hi, I have a scheduled task that runs some macros in excel which make calls to a .dll, I am not 100% sure what goes on behind the scenes in the .dll but have been experiencing very strange phenomonons....

If I am logged into the machine the scheduled task runs no problem, both on the timer and if I run it via the scheduled task panel in the control panel by right clicking on the task. when I log off the machine, the the task will still run, but it crashes somewhere in the .dll and I do not know wtf is going on... I just lock the machine with my user, it all runs okay, but its when i log off that the application craps out...

the task is set to run under my username when it runs, so I am not sure why it matters that I am logged in... please help... this is all running on server 2003 with office 2000. I need to be able to get this thing to run without me having to be logged in....

thanks. Marc
Avatar of iCoreKC
iCoreKC
Flag of United States of America image

My first thought is that the .dll file is in a directory with security limitations.  

Are you seeing anything in the Event Viewer?  If so, please post the Event ID and information.

Avatar of Bruce Cadiz
mrferrari,

 What you need to do is set up the task in the task scheduler to run under a system account (NT AUTHORITY\SYSTEM). Your personal account has suffiecient priviledges to run the macros / access the .dll but when you are logged off it cannot run / access the files.  NT AUTHORITY\SYSTEM should run no matter what / who is logged on/off. If you have admin rights you won't need to enter a password when creating the scheduled task.

Bruce

How are you starting Excel in the task?
Avatar of mrferrari

ASKER

there is nothing being show in the event viewer. the task runs and completes, but somewhere in the code it crashes the loop stops and i get 0's written into my database instead of the actual values I am trying to generate.
what is the NT AUTHORITY\SYSTEM, I have tried to put this in and it still asks for a password... is it exactly "NT AUTHORITY\SYSTEM" or is mydomain\system, etc. I tried several things, all required me to put in a password.

I also tried to create the scheduled task via the cmd promot, same issue occurs as in the main questions described above.
got NT AUTHORITY\SYSTEM to fill in, but then the task does not even run...
mrferrari,

To enter the NT AUTHORITY\SYSTEM you need to have Administration Rrights on the computer. You do have Admin Rights on this computer / server?

Bruce
bruce, i got it going, but then the task didnt even run... im still buggered at the moment... not sure if the dll is screwing me up or the specified user the task is running as is not working properly... thx Marc
Mark,

Try this, create another simpler task say a command file that echos some text to a file
example: "echo test file > test.txt" then save as a test.cmd file.
Put it in the scheduler, set it for a few minutes ahead and log out.

Then you can log back on and see if the task scheduler is executing properly. if so then you can be sure something else is the problem.

Bruce
Hi Bruce, I know the task runs fine... b/c I get entries written into my database, but it seems that somehow the dll is checking to see if there is a user that is logged into the machine or has the machine locked. in that situation it all run fine, if no user is logged in or I end the remote connection to the server, the one piece of code in the dll fails and then returns to me a 0... its something in the dll, but I thought that using run as tell s the computer to use the account specified. clearly there is still some parameter left out and it knows noone is actually logged onto the machine. perhaps its some sort of connection its looking for... thx for the help.
Marc
Marc,

What exactly is the code you wrote and .dll soing? Perhaps is it connection to an MS SQL database and pulling data and authenticating via the logged in user? That would be the thing that makes sense based on what you've described.

Bruce
thx for the comment... the code runs some simulations and it runs on lots of computers so it must not know who is logged in nor care, but it seems that it requires a user to be logged in. ive tried everything. the code in the dll stops running and exits the function when noone is connected to the machine... I need to figure out how to trick or something...

thx, Marc
Marc,

 Is this a custom .dll you / some has written or something from Microsoft/another company? What is it doing exactly?

Bruce
this is dll that came to me from a third party vendor that I do not want to name on the forum, I open excel and pull in data from my database. it then runs some more code and calls a "dll" file that I have on the machine and goes through a monte carlo simulation of 5,000,000 trials. but when not logged in it only runs one trial and returns a 0 instead of the actual computation... Im not sure what its exactly doing or where it is exactly crashing... it just appears that the server is not running the code identically as though the user is logged into the box... thanks for any help. im really buggers stuck on this one. Marc
I could send you the file and dll if you would like... but not sure if that would help... seems like in the dll its looking for the logged on user but I cannot tell... thx again for even taking the time to think about this with me... Marc
ASKER CERTIFIED SOLUTION
Avatar of Bruce Cadiz
Bruce Cadiz
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I finally decided to run the script using my local machines scheduled task manager. I usually lock my PC overnight and the scripts work fine when the machine is locked. On the server I could not be sure I would stay logged in b/c system admin could go into the machine and then logoff... this was the best I could do.
Please close questions, I would like to award c336914 the 500 points for helping, but his answer was not the utilized solution. Is that possible?
thx