By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,143 Members | 1,919 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,143 IT Pros & Developers. It's quick & easy.

Problem with Impersonation to execute batch file via ASP.Net

P: n/a
I need to execute a batch file via ASP.Net. In my VB.Net code, I'm
using System.Diagnostics.Process to call the batch file and its
appropriate command line arguments. I'm using
System.Diagnostics.Process.StandardError and
System.Diagnostics.Process.StandardOutput to capture and view the
output and error messages. My web.config file has the following:

<identity impersonate="true" userName="administrator"
password="password" />

I'm also using
System.Security.Principal.WindowsIdentity.GetCurre nt().Name to verify
that Impersonation is working and that the process is being executed
under the correct username.

The response I get is "Access Is Denied".

For testing reasons, I've changed the VB code to call a command line
function instead of my batch file, and if the command line function
does not make any changes to the system, the output is returned as
expected. If the command line function makes a change, I get the
response of Access Is Denied.

For example, if I run:
cacls /?
The output is the instructions for the cacls function.

But if I run:
cacls test.bat /e /g administrator:F
The response is Access is denied.

I've also tried using schtasks to add my batch file as a scheduled task
via the command line. If I run:
schtasks /?
The ouput is the instructions for the schtasks function.

But if I run:
schtasks /create /s \\SERVERNAME /U administrator /P password /RU
administrator /RP password /SC ONCE /TN RunMyBATFile /TR C:\test.bat
/ST 23:30:00
The output is "Access Is Denied"

All of my command line calls are tested on my local machine, so I know
that there are no syntax problems. Impersonation "appears" to be
working based on the output of
System.Security.Principal.WindowsIdentity.GetCurre nt().Name. But the
admin. account should have complete access to this system, but I must
be missing something. Please help!!!

-E

Jul 18 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.