Click here to Skip to main content
15,905,504 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi Friends,

How to run Server Computers Application from my local system. My application exe in Server in F folder its shared. I am able to access using run command and run my application. I need program to execute the Server applications using C# asp.net.

Thanks,
Suresh
Posted

1 solution

Being able to access a shared folder doesn;t mean you have any rights to execute applications on that server - just that you can run applications hosted on the server on your local machine. For security reasons - to prevent malicious code being run on your PC if nothing else - this is not "normal" activity.

You will need authorization for the remote PC, but then see here: Create a Remote Process using WMI in C#[^]
 
Share this answer
 
Comments
itsureshuk 20-Oct-15 10:02am    
Hi OriginalGriff,
In ASP.NET application i am trying to implement Run Remote Application.

I am using below code
http://stackoverflow.com/questions/15937167/run-a-command-in-a-windows-remote-server-and-get-back-the-console-output-in-c-sh/15942781#15942781

public string executeCommand(string serverName, string username, string password, string domain=null, string command)
{
try
{
System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.RedirectStandardOutput = true;
startInfo.UseShellExecute = false;
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
startInfo.FileName = "cmd.exe";
if (null != username)
{
if (null != domain)
{
startInfo.Arguments = "/C \"psexec.exe \\\\" + serverName + " -u " + domain+"\\"+username + " -p " + password + " " + command + "\"";
}
else
{
startInfo.Arguments = "/C \"psexec.exe \\\\" + serverName + " -u " + username + " -p " + password + " " + command + "\"";
}
}
else
{
startInfo.Arguments = "/C \"utils\\psexec.exe "+serverName+" "+ command + "\"";
}
process.StartInfo = startInfo;
process.Start();
process.WaitForExit();

if (process.ExitCode == 0 && null != process && process.HasExited)
{
return process.StandardOutput.ReadToEnd();
}
else
{
return "Error running the command : "+command;
}
}
catch (Exception ex)
{
throw ex;
}
}


But i am getting error, my server application is not running.And also i need to run My asp.net application in domain (hosting server), so user while clicking automatically should run.

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