views:

423

answers:

1

I would like to run a bat script on one of the machines on the domain, from my asp.net application. Machine with the batch script is a temporary storage machine, and script synchronizes it with the permanent storage machine. So, what is the optimal way of doing this?

The thing I tried is to use PsExec to run a script on the remote machine. I create a process that makes a PsExec call, and it actually does it's job pretty well. However, since the ASP.NET worker thread runs under ASP.NET account that has restricted privileges, I must hard-code my domain user credentials in PsExec call, and that's something I do not like doing.

Is there a way to overcome this problem, or maybe some other approach that I could try?

Thanks...

+1  A: 

You can use the <identity impersonate="true" /> setting in your Web.config to have the application run under the IUSR, or you can set a username/password on the identity tag to an account you'd like to use to run the BAT file.

I had previously found some details on Impersonate over at: http://www.aspdev.org/articles/web.config/

But I'm sure a quick web search will find you even more info on Impersonate.

Jay S