I am trying to execute PSExec
from my Asp.Net Web application to connect to a remote server. Somehow it gives "Access Denied Error -5"
with no credentials set, and by setting the credentials in the PSEXEC command it gives "2250 Network connection could not be found"
. I am an admin on the server and i have Windows authentication and Asp.Net Impersonation
enabled (IIS7.5
). More interestingly when i try to execute this from a console application
or a even just using the command prompt
it just works fine. I am trying to do just a ping operation as a test.
Here is my code snippet:-
var startInfo = new ProcessStartInfo{
CreateNoWindow = true,
UseShellExecute = false,
FileName = FilePath,
Arguments = CommandArgs
}
Process vsCommandProcess = Process.Start(startInfo);
vsCommandProcess.WaitForExit();
var exitCode = vsCommandProcess.ExitCode;
if (vsCommandProcess.ExitCode != 0)
{
...rest of the code
Here:-
FilePath --> C:\pstools\psexec.exe
Arguments --> \\servername -accepteula -u domain\userName -p password ipconfig (1)
\\servername -accepteula ipconfig (2)
(1) Gives Error 2250 (2) gives Error 5
The same command and code works with a console application. SO i believe it definitely is something to do with the Asp.net application which is not able to carry over the credentials to remote to the machine. I event tried startInfo.LoadUserProfile
but for no avail.
Appreciate your help. I tried to look up for similar questions but couldn't find a solution for the problem i am facing.