SiComponents Home Page SiComponents Forums
Here you will be able to get help and share your experience
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Cannot run task scheduler under non-admin accounts.

 
Post new topic   Reply to topic    SiComponents Forums Forum Index -> VCL Scheduling Agent
View previous topic :: View next topic  
Author Message
shaune



Joined: 19 Apr 2004
Posts: 6

PostPosted: Wed Jun 02, 2004 11:26 am    Post subject: Cannot run task scheduler under non-admin accounts. Reply with quote

Hi

My program creates tasks dynamically using TTaskScheduler.

The Problem :
The program executes fine under a computer administrator account and creates the tasks, but if i login and run the program under a non-admin user (or called a limited user ) the tasks do not get scheduler and return an error 'the task scheduler service is not running'. This error is created when one calls the create method for TTaskScheduler.

The Task Schedular service is running and one can manual add a task using the microsofts task scheduler wizard under a non-admin account.



Thanks.
Back to top
View user's profile Send private message Send e-mail
isiticov
Site Admin


Joined: 21 Nov 2002
Posts: 2102

PostPosted: Wed Jun 02, 2004 1:15 pm    Post subject: Reply with quote

Please check the following:
1) TTaskScheduler.Open is called after application startup
2) Task Scheduler Service is running in Automatic mode. This service could be started only by System and Power Users. To check its mode open Control Panel - Administrative Tools - Services and in the services list check the startup mode for Task Scheduler Service.
Back to top
View user's profile Send private message
shaune



Joined: 19 Apr 2004
Posts: 6

PostPosted: Thu Jun 03, 2004 8:34 am    Post subject: Reply with quote

HI

This is a what i am doing - a summary version

procedure TfrmMain.Button1Click(Sender: TObject);
var
TaskScheduler: TTaskScheduler;
begin
TaskScheduler := TTaskScheduler.Create(nil);
TaskScheduler.Open;
showmessage('done');
TaskScheduler.close;
TaskScheduler.Destroy;
end;

It never gets to the showmessage.


The Task Scheduler Service is running and in Automatic mode and is started, the service is started by the local system account.
Back to top
View user's profile Send private message Send e-mail
isiticov
Site Admin


Joined: 21 Nov 2002
Posts: 2102

PostPosted: Thu Jun 03, 2004 1:44 pm    Post subject: Reply with quote

Could you please specify what OS do you use?
Unfortunately, we were unable to reproduce your situation.
Could you please try the following code:

Code:
procedure TfrmMain.Button1Click(Sender: TObject);
var
TaskScheduler: TTaskScheduler;
begin
TaskScheduler := TTaskScheduler.Create(nil);
if TaskScheduler.StartScheduler then 
  ShowMessage('Scheduler started!')
else
  ShowMessage('Scheduler failed to start!');
TaskScheduler.Open;
showmessage('Opened!');
TaskScheduler.Close;
TaskScheduler.Desctroy;
end;
Back to top
View user's profile Send private message
isiticov
Site Admin


Joined: 21 Nov 2002
Posts: 2102

PostPosted: Thu Jun 03, 2004 1:45 pm    Post subject: Reply with quote

Also could you please test if the demo application included into delivery fails to work under restricted account as well?
Back to top
View user's profile Send private message
shaune



Joined: 19 Apr 2004
Posts: 6

PostPosted: Thu Jun 03, 2004 2:12 pm    Post subject: Reply with quote

Hi

I have tested the supplied code.

It works fine with a account with admin rights(I get both showmessages) but when logged on as a non-admin user it does not even get to showmessage and bombs at startscheduler.

I am using window XP pro Version 2002 service pack 1 - and has the latest updates from microsofts windows update site.

I created the non-admin(limited) user using the 'User accounts' applet in the 'control panel.

Thanks.
Back to top
View user's profile Send private message Send e-mail
isiticov
Site Admin


Joined: 21 Nov 2002
Posts: 2102

PostPosted: Fri Jun 04, 2004 6:39 am    Post subject: Reply with quote

How does the demo application work under restricted account?
Back to top
View user's profile Send private message
shaune



Joined: 19 Apr 2004
Posts: 6

PostPosted: Fri Jun 04, 2004 9:19 am    Post subject: Reply with quote

Hi

The limited user account result :

once you run the program and click on the button you immediatly get the error :

'Task Scheduler service is not running'

no showmessage is executed.

I will try to run the demo application on some other Operating systems.

thanks
Back to top
View user's profile Send private message Send e-mail
mike71



Joined: 18 Jan 2005
Posts: 4

PostPosted: Tue Jan 18, 2005 6:38 pm    Post subject: Reply with quote

I'm having this same problem, but only when compiled under Delphi 7. The Delphi 2005 compiled version works under a non-admin account, but has a different problem (won't let me clear the tfRunOnlyWhenLoggedOn flag, see my other post) and at any rate our production app is currently written under Delphi 7 so we need this version to work.

When I run the Demo application compiled with Delphi 7 under a straight Users member account, I get an immediate Windows fatal application error box and then a message dialog after I close that indicating that the Task Scheduler service is not running, even though the service is most definitely running. If I attempt to open the Demo project in Delphi 7 when running as this non-admin user, I get an error opening the main form that the Task Scheduler service is not running and the SI Components are removed from the form.
Back to top
View user's profile Send private message
mike71



Joined: 18 Jan 2005
Posts: 4

PostPosted: Wed Jan 19, 2005 5:39 pm    Post subject: Reply with quote

This seems to be an issue just with the Trial version for me. When I ran the registered version, the problem went away.
Back to top
View user's profile Send private message
isiticov
Site Admin


Joined: 21 Nov 2002
Posts: 2102

PostPosted: Wed Jan 19, 2005 8:01 pm    Post subject: Reply with quote

Thank you for details. We will try to investigate what could be a reason for this.
Back to top
View user's profile Send private message
bartonkt



Joined: 10 Mar 2005
Posts: 1

PostPosted: Fri Mar 11, 2005 3:52 pm    Post subject: Reply with quote

I had this bug as well, but fixed it by modifying the TTaskScheduler.StartScheduler function. I only modified the code for WinNT/2k/XP, making a change to how the rights for the service are obtained. For me, I was getting the same error message as everyone "Task Scheduler service not running", tracked it down to when we did TTaskScheduler.Open, which in turn calls StartScheduler(). Here is the code we modified, starting at the WinNT/2k/XP branch.

Code:

else
begin
hSC := OpenSCManager(nil, nil, SC_MANAGER_CONNECT);
if hSC = 0 then
Result := GetLastError = 0
else
begin

// 1.0.4
hSchSvc := OpenService(hSC, SCHED_SERVICE_NAME, SERVICE_QUERY_STATUS);
if hSchSvc = 0 then
hSchSvc := OpenService(hSC, SCHED_SERVICE_NAME, SERVICE_START);

CloseServiceHandle(hSC);
if hSchSvc = 0 then
Result := GetLastError = 0
else
begin
if not QueryServiceStatus(hSchSvc, SvcStatus) then
begin
CloseServiceHandle(hSchSvc);
Result := GetLastError = 0;
end
else
begin
if SvcStatus.dwCurrentState = SERVICE_RUNNING then
begin
CloseServiceHandle(hSchSvc);
Result := True;
end
else
begin
ServiceArgVectors := nil;
//changed code here
CloseServiceHandle(hSchSvc);
hSC := OpenSCManager(nil, nil, SC_MANAGER_CONNECT);
hSchSvc := OpenService(hSC, SCHED_SERVICE_NAME, SERVICE_START);
CloseServiceHandle(hSC);
if not StartService(hSchSvc, 0, ServiceArgVectors) then
begin
CloseServiceHandle(hSchSvc);
Result := GetLastError = 0;
end
else
begin
CloseServiceHandle(hSchSvc);
Result := True;
end;
end;
end;
end;
end;
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    SiComponents Forums Forum Index -> VCL Scheduling Agent All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by p h p B B  © 2001, 2005 p h p B B  Group