Rob.Oakshott
Rob.Oakshott

Reputation: 35

How to invoke a Windows Scheduled task or a batch file on a server different to the IIS server

I have a asp.net web site, I would like a page on that site to be able to invoke a Windows Scheduled task or a batch file on a server different to the IIS server?

Is it possible? How should I do this?

Upvotes: 1

Views: 1231

Answers (2)

codeConcussion
codeConcussion

Reputation: 12938

Try PsExec. It's a free tool from Microsoft that will let you execute processes remotely.

Make sure to check out all the other tools in the Sysinternals Suite; there's some really good stuff in there.

Upvotes: 1

Brandon J. Boone
Brandon J. Boone

Reputation: 16472

Simplest way would be to place a Web Service on the server that needs to run the scheduled task/batch file (we'll call this SERVER1). That service should have a method that will invoke the scheduled task/batch file (we'll call this method Invoke).

Then from the asp.net web site on the other server (SERVER2), we'll add a link to run our method on SERVER1, http://SERVER1/YourWebService.asmx/Invoke.

To me this would be the easiest way to manipulate SERVER1 from an outside entity (In your case an asp.net web site).

Note: You may run into security issues with your Web Service invoking scheduled tasks and running batch files. I believe it can be done, but you may need to play with your .Net permission settings.

Upvotes: 1

Related Questions