Schedule Tasks - Difference between cmd line and using com api

G

Guest

Some background:

I have an application written in java that uses the java Runtime class to
issue schtasks command to windows xp. I want to be able to create the task
without the user of my java application having to enter their windows profile
username and password. It appears that this is possible using the com api,
but I cannot figure out how to do it using schtasks commands.

The reason that I say it is possible through the com api (ie: calling the
windows gui) is because in Norton antivirus, I can setup a scheduled scan
without having to enter in my windows profile username and password. Once I
set up the task, if I go into windows task manager from control panel, and
look at the properties. On the Task tab I can see the Run as is set to my
windows profile username and the set pasword button is disabled and the Run
only if logged on check box is checked. If I uncheck this check, then the
windows gui makes me enter a password.

So, from looking at the documentation on how schtasks works in XP, I don't
see a way to set the Run only if logged on option in schtasks.
Does anyone know of a way to set that option using schtasks? I believe that
will give me the desired behavior
 
P

Pegasus \(MVP\)

gadawgs said:
Some background:

I have an application written in java that uses the java Runtime class to
issue schtasks command to windows xp. I want to be able to create the task
without the user of my java application having to enter their windows profile
username and password. It appears that this is possible using the com api,
but I cannot figure out how to do it using schtasks commands.

The reason that I say it is possible through the com api (ie: calling the
windows gui) is because in Norton antivirus, I can setup a scheduled scan
without having to enter in my windows profile username and password. Once I
set up the task, if I go into windows task manager from control panel, and
look at the properties. On the Task tab I can see the Run as is set to my
windows profile username and the set pasword button is disabled and the Run
only if logged on check box is checked. If I uncheck this check, then the
windows gui makes me enter a password.

So, from looking at the documentation on how schtasks works in XP, I don't
see a way to set the Run only if logged on option in schtasks.
Does anyone know of a way to set that option using schtasks? I believe that
will give me the desired behavior

If you schedule the task under the local System account then
you don't need to enter any credentials.
 
G

Guest

Thanks for the reply.

To create the tasks under the System account is what I originally planned to
do.
However, when I create the task under the System account, I can see it in
Scheduled Tasks, and at the proper time it runs, but I don't get the behavior
that I am looking for. Basically, the task runs a jar file and displays a
gui component in the lower right hand corner of the screen. If I create the
task with the windows profile username and password of my windows user, the
task runs and at the proper time I see my gui component on my screen. If the
task is created at the System level, it runs but I see nothing.

Here is what appears in the ScheLgU.txt related to the run:
"Test.job" (javaw) 9/14/2006 9:53:00 AM ** WARNING **
Invalid working directory..
The specific error is:
0x00000002: The system cannot find the file specified.
Verify that the directory exists and try again.
"Test.job" (javaw)
Started 9/14/2006 9:53:00 AM
"Test.job" (javaw)
Finished 9/14/2006 9:53:06 AM
Result: The task completed with an exit code of (0).
[ ***** Most recent entry is above this line ***** ]


After reading the following in the documentation about System level tasks I
assumed that I could not use them based on what I need to do.

The NT Authority\System account does not have interactive logon rights.
Users do not see and cannot interact with programs run with system
permissions.

So I am not sure at this point that I can get the proper behavior without
using the com api instead of schtasks command line.

Any help is greatly appreciated
 
P

Pegasus \(MVP\)

You can't have it both ways.

If you don't want to enter any credentials then you can schedule
the job under the System account. It will then run invisibly in the
background and it will have no access to networked resources.

If you're happy to enter account credentials then you can schedule
the job under your own account. It will now run visibly in the
foreground and it will have access to the same networked resources
as you have.


gadawgs said:
Thanks for the reply.

To create the tasks under the System account is what I originally planned to
do.
However, when I create the task under the System account, I can see it in
Scheduled Tasks, and at the proper time it runs, but I don't get the behavior
that I am looking for. Basically, the task runs a jar file and displays a
gui component in the lower right hand corner of the screen. If I create the
task with the windows profile username and password of my windows user, the
task runs and at the proper time I see my gui component on my screen. If the
task is created at the System level, it runs but I see nothing.

Here is what appears in the ScheLgU.txt related to the run:
"Test.job" (javaw) 9/14/2006 9:53:00 AM ** WARNING **
Invalid working directory..
The specific error is:
0x00000002: The system cannot find the file specified.
Verify that the directory exists and try again.
"Test.job" (javaw)
Started 9/14/2006 9:53:00 AM
"Test.job" (javaw)
Finished 9/14/2006 9:53:06 AM
Result: The task completed with an exit code of (0).
[ ***** Most recent entry is above this line ***** ]


After reading the following in the documentation about System level tasks I
assumed that I could not use them based on what I need to do.

The NT Authority\System account does not have interactive logon rights.
Users do not see and cannot interact with programs run with system
permissions.

So I am not sure at this point that I can get the proper behavior without
using the com api instead of schtasks command line.

Any help is greatly appreciated

Pegasus (MVP) said:
Once
I the
Run

If you schedule the task under the local System account then
you don't need to enter any credentials.
 
G

Guest

ok, so by scheduling a job under the System account, the task has to be able
to run in the background, meaning that no gui components can be diplayed
(even if the user doesn't interact with the gui, other than seeing it)
because visibilty is a foreground function?

If the above is true, then it seems that my only option to get my desired
behavior is the use the com api instead of schtasks.exe. In much the same
way that norton antivirus (or many other applications) seem to do it, because
those tasks are created as "Run only if logged on", which doesn't require a
password. And that option doesn't appear to be available using schtasks.exe
for Windows XP. It does appear to be an option on schtasks for Windows
Server 2003 with the /it option, but that doesn't help me.

So I think I have to change to the com api to make this work?

Thanks

Pegasus (MVP) said:
You can't have it both ways.

If you don't want to enter any credentials then you can schedule
the job under the System account. It will then run invisibly in the
background and it will have no access to networked resources.

If you're happy to enter account credentials then you can schedule
the job under your own account. It will now run visibly in the
foreground and it will have access to the same networked resources
as you have.


gadawgs said:
Thanks for the reply.

To create the tasks under the System account is what I originally planned to
do.
However, when I create the task under the System account, I can see it in
Scheduled Tasks, and at the proper time it runs, but I don't get the behavior
that I am looking for. Basically, the task runs a jar file and displays a
gui component in the lower right hand corner of the screen. If I create the
task with the windows profile username and password of my windows user, the
task runs and at the proper time I see my gui component on my screen. If the
task is created at the System level, it runs but I see nothing.

Here is what appears in the ScheLgU.txt related to the run:
"Test.job" (javaw) 9/14/2006 9:53:00 AM ** WARNING **
Invalid working directory..
The specific error is:
0x00000002: The system cannot find the file specified.
Verify that the directory exists and try again.
"Test.job" (javaw)
Started 9/14/2006 9:53:00 AM
"Test.job" (javaw)
Finished 9/14/2006 9:53:06 AM
Result: The task completed with an exit code of (0).
[ ***** Most recent entry is above this line ***** ]


After reading the following in the documentation about System level tasks I
assumed that I could not use them based on what I need to do.

The NT Authority\System account does not have interactive logon rights.
Users do not see and cannot interact with programs run with system
permissions.

So I am not sure at this point that I can get the proper behavior without
using the com api instead of schtasks command line.

Any help is greatly appreciated

Pegasus (MVP) said:
Some background:

I have an application written in java that uses the java Runtime class to
issue schtasks command to windows xp. I want to be able to create the
task
without the user of my java application having to enter their windows
profile
username and password. It appears that this is possible using the com
api,
but I cannot figure out how to do it using schtasks commands.

The reason that I say it is possible through the com api (ie: calling the
windows gui) is because in Norton antivirus, I can setup a scheduled scan
without having to enter in my windows profile username and password. Once
I
set up the task, if I go into windows task manager from control panel, and
look at the properties. On the Task tab I can see the Run as is set to my
windows profile username and the set pasword button is disabled and the
Run
only if logged on check box is checked. If I uncheck this check, then the
windows gui makes me enter a password.

So, from looking at the documentation on how schtasks works in XP, I don't
see a way to set the Run only if logged on option in schtasks.
Does anyone know of a way to set that option using schtasks? I believe
that
will give me the desired behavior


If you schedule the task under the local System account then
you don't need to enter any credentials.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top