I am making a Windows Form Program where I can be able to connect to an FTP Server to download data to show it to the user. I have to make the app in a way that the user can also connect through a gateway. I made the next function to log on through a gateway:
private Boolean addRoute(string ip, string gw)
{
string arg = String.Format("ADD {0} MASK 255.255.255.255 {1}", ip, gw);
return startProcess("route.exe", arg, 10000, true);
}
private Boolean startProcess(String fileName, String arguments, int timeout, bool admin)
{
try
{
Process process = new Process();
process.StartInfo.FileName = fileName;
if (System.Environment.OSVersion.Version.Major >= 6)
{
//if (admin) { process.StartInfo.UserName = "admin"; }
//process.StartInfo.UserName = "admin";
}
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.UseShellExecute = false;
process.StartInfo.Arguments = arguments;
process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
process.Start();
if (timeout > 0)
{
if (process.WaitForExit(timeout))
{
return true;
}
else
{
return false;
}
}
else
{
process.WaitForExit();
return true;
}
}
catch (Exception e)
{
Global.LogMessageToFile(e.Message);
return false;
}
}
This code works perfect with my PC but when I test it in other PC's with Windows 7 doesn't work anymore.
I thought there was a problem with the UAC permissions so I did the solution adapted to the second answer of the link Selectively disabling UAC for specific programs on Windows Programatically but it doesn't seem to be the problem.
Do you have any other ideas about how can I accomplish this with the code of my program?
EDIT I have been blocked to post comments, so I will answer that I have no exceptions, and what I need is connect to a lower level, from one network to another, through a gateway. That's why I have adopted this solution.