I'm tasked with automating an internal process. This process involves first being logged on a remote server (A). From server A, a user would connect to Remote Server (B).
Once authenticated onto Server B, the C# application needs to run a batch file
I've used some sample code form a post on CodeProject to make all the remote desktop connections through some GUI and it's working without issue. The codes uses the ActiveX MSTSC Library.
I then sue this block of code, hoping to start the Batch File:
private void button3_Click(object sender, EventArgs e)
{
try
{
//PowerShell ps = PowerShell.Create();
//ps.AddCommand("Start-Process");
//ps.AddArgument("/c c:\\Recycle.bat");
//ps.Invoke();
Process p = new Process();
p.StartInfo.FileName = "C://Recycle.bat";
p.StartInfo.CreateNoWindow = false;
p.Start();
}
catch(Exception exception)
{
Console.WriteLine(exception.Message);
}
}
I've tried using the PowerShell class, as well as the System.Diagnostics.Process objects. The PS object yeilds "no file found", where the process objects executes the "Recycle.bat" script on my local computer, not the remote server.
How would you attach the Process object to the remote server and not my local PC?
Thank you for your help.