0

I'm trying to run the following scrip on my WCF service hosted on my computer.

string exePath = "C:\\Windows\\SysWOW64\\WindowsPowerShell\\v1.0\\powershell.exe";
            var ps1 = new ProcessStartInfo();
            ps1.FileName = exePath;
            ps1.Arguments = "-ExecutionPolicy Bypass -File C:\\Users\\fn070084\\Desktop\\Test2.ps1";
            ps1.WorkingDirectory = Path.GetDirectoryName(exePath);
            Process.Start(ps1);
            

If I run just this code, it runs correctly on Visual studio, but when I put it on a service on the WCF server it's not doing something.

The code for the Test2 File is this one

$LogFile = "\\ComputerName\C$\powershellLog" + $LongTime + ".txt" "Hello, I'm running Powershell through C#" >>$logFile

Note: I wrote it as "ComputerName" but on my actual code I'm having the the rigth computer name.

1 Answers1

0

First ,make sure that the server on which the WCF Service is installed is able to access and invoke the service, as you can see in this docs.

In addition, your own computer should be able to communicate with the server, the call method can be accessed. Refer to this post.

Jiayao
  • 510
  • 3
  • 7