raja king
raja king

Reputation: 31

How to run a Powershell script from WCF in C#

I have java application which needs run dynamically through the power shell with my WCF c# application. I have tried the following command

System.Diagnostics.Process.Start("powershell.exe", strCmd + " ; timeout 50");

But still I am unable to succeed could tell me how can I do it

Upvotes: 0

Views: 829

Answers (1)

Shiraz Bhaiji
Shiraz Bhaiji

Reputation: 65461

There are several Things that could be wrong here:

  • Does the WCF service have the required rights to run the PowerShell command?
  • Will the PowerShell command be executed in the correct Directory?
  • Should the conncatination be done before the start command?

Having said that, this is not a good idea, you are opening Your machine to attackers to run any PowerShell script they want.

Upvotes: 1

Related Questions