Odd Scheduled Task Behavior

A

A. Lovhaug

I have a console application built in the .NET Framework.
This application basically executes an XCopy based on
parameters that I pass to it. I use it for creating
scripts for backing up folders, etc.

All my command scripts utilizing this console application
work fine when they are executed interactively. However,
if they are executed via a scheduled task, they do not
run. Or more precisely, the script seems to execute at the
appropriate time (a command window flashes), but the
folder copies are never created, and the window disappears
way too quickly. There are no errors registered in the
event logs.

I figured it was a security problem (I'm copying to a hard
drive on another computer), so I created a command script
that used the actual XCopy statement that .NET application
generates (and I know it generates it correctly because it
works fine except as a scheduled task). I then scheduled
this new script as a scheduled task. I assumed that there
was some security context problem, and that the XCopy
statement wouldn't work either from a scheduled task.
However, amazingly, it works just fine.

Now I'm trying to figure out what to try next. Is there
anything special that is required to successfully get
a .NET console application to run from a command script
via a scheduled task? FYI - I'm using Windows XP, Visual
Studio 2003 and the .NET Framework 1.1.

Any suggestions would be greatly appreciated.

A. Lovhaug
 
E

Ed Kaim [MSFT]

Does the owner of the sceduled task have permissions to access the app? If
the task is running under a different, less-privileged owner, then it might
not be able to run. Is there an error log?
 
P

Phil Wilson

You're probably running under the local system account, and that account has no
network permissions.
 
A

A. Lovhaug

If by "Owner of the scheduled task" you mean the user
indicated in the "Run as" textbox, then the answer is yes,
they should have permissions to access the app. The user
indicated in the "Run as" textbox is the same user who is
logged in interactively when the commnd script is run
manually.

No, there is no error log entry for this. Perhaps I'll try
to change the audit policy to see if I can view any
additional error information. But that's part of why I'm
mystified - I'm not getting any error information to help
point me.
 
A

A. Lovhaug

Hmmm. So, if I understand you correctly, you are saying
that a scheduled task that executes a .NET framework
application is running under the local system account,
even if the "Run As" textbox indicates another user? Wow,
that is surprising to me.

If so, it seems to be something unique to running the .NET
application, since running the same XCopy command in a
command script was able to access the network drive fine.
I wonder how I could work around such a limitation?
-----Original Message-----
You're probably running under the local system account, and that account has no
network permissions.
--
Phil Wilson [MVP Windows Installer]
----
A. Lovhaug said:
I have a console application built in the .NET Framework.
This application basically executes an XCopy based on
parameters that I pass to it. I use it for creating
scripts for backing up folders, etc.

All my command scripts utilizing this console application
work fine when they are executed interactively. However,
if they are executed via a scheduled task, they do not
run. Or more precisely, the script seems to execute at the
appropriate time (a command window flashes), but the
folder copies are never created, and the window disappears
way too quickly. There are no errors registered in the
event logs.

I figured it was a security problem (I'm copying to a hard
drive on another computer), so I created a command script
that used the actual XCopy statement that .NET application
generates (and I know it generates it correctly because it
works fine except as a scheduled task). I then scheduled
this new script as a scheduled task. I assumed that there
was some security context problem, and that the XCopy
statement wouldn't work either from a scheduled task.
However, amazingly, it works just fine.

Now I'm trying to figure out what to try next. Is there
anything special that is required to successfully get
a .NET console application to run from a command script
via a scheduled task? FYI - I'm using Windows XP, Visual
Studio 2003 and the .NET Framework 1.1.

Any suggestions would be greatly appreciated.

A. Lovhaug


.
 
P

Phil Wilson

I didn't mean to imply that at all. I'm responding to your original post, and
that doesn't seem to say anything about doing a "run as".
It's nothing to do with .NET, just the case that a process running under the
local system account has no network privileges. If you're using the the "AT
<time>" command, that's a fairly well-known technique for running a process
under the local system account, and that seems to be what's happening here.
--
Phil Wilson [MVP Windows Installer]
----
A. Lovhaug said:
Hmmm. So, if I understand you correctly, you are saying
that a scheduled task that executes a .NET framework
application is running under the local system account,
even if the "Run As" textbox indicates another user? Wow,
that is surprising to me.

If so, it seems to be something unique to running the .NET
application, since running the same XCopy command in a
command script was able to access the network drive fine.
I wonder how I could work around such a limitation?
-----Original Message-----
You're probably running under the local system account, and that account has no
network permissions.
--
Phil Wilson [MVP Windows Installer]
----
A. Lovhaug said:
I have a console application built in the .NET Framework.
This application basically executes an XCopy based on
parameters that I pass to it. I use it for creating
scripts for backing up folders, etc.

All my command scripts utilizing this console application
work fine when they are executed interactively. However,
if they are executed via a scheduled task, they do not
run. Or more precisely, the script seems to execute at the
appropriate time (a command window flashes), but the
folder copies are never created, and the window disappears
way too quickly. There are no errors registered in the
event logs.

I figured it was a security problem (I'm copying to a hard
drive on another computer), so I created a command script
that used the actual XCopy statement that .NET application
generates (and I know it generates it correctly because it
works fine except as a scheduled task). I then scheduled
this new script as a scheduled task. I assumed that there
was some security context problem, and that the XCopy
statement wouldn't work either from a scheduled task.
However, amazingly, it works just fine.

Now I'm trying to figure out what to try next. Is there
anything special that is required to successfully get
a .NET console application to run from a command script
via a scheduled task? FYI - I'm using Windows XP, Visual
Studio 2003 and the .NET Framework 1.1.

Any suggestions would be greatly appreciated.

A. Lovhaug


.
 

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