Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
SshNet library for safe connection to Windows Server from asp.net. Now I ant to start\stop any process running on Task Manager. Is it done using PowerShell or any other way? If yes than how can I start PowerShell and than run command from asp.net
C#
ConnectionInfo connectionInfo = new PasswordConnectionInfo(ip, port, userid, password);
    using (Renci.SshNet.SshClient client = new Renci.SshNet.SshClient(connectionInfo))
    {
        client.Connect();
        //What should I do here to open PowerShell
        var cmd = client.RunCommand("Get-Command");
        lbl.Text = "Output: " + cmd.Result;
        client.Disconnect();
    }

Running above code I am getting following error: AllowDesktopAccess failed. Unable to execute command or shell on remote system: Failed to Execute process

Does this mean that I cannot execute PowerShell command from asp.net?
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900