internal class LaunchEXE { internal static string Run(string exeName, string argsLine, int timeoutSeconds) { StreamReader outputStream = StreamReader.Null; string output = ""; bool success = false; try { Process newProcess = new Process(); newProcess.StartInfo.FileName = exeName; newProcess.StartInfo.Arguments = argsLine; newProcess.StartInfo.UseShellExecute = false; newProcess.StartInfo.CreateNoWindow = true; newProcess.StartInfo.RedirectStandardOutput = true; newProcess.Start(); if (0 == timeoutSeconds) { outputStream = newProcess.StandardOutput; output = outputStream.ReadToEnd(); newProcess.WaitForExit(); } else { success = newProcess.WaitForExit(timeoutSeconds * 1000); if (success) { outputStream = newProcess.StandardOutput; output = outputStream.ReadToEnd(); } else { output = "Timed out at " + timeoutSeconds + " seconds waiting for " + exeName + " to exit."; } } } catch (Exception e) { throw (new Exception("An error occurred running " + exeName + ".", e)); } finally { outputStream.Close(); } return "\t" + output; } }Now, I just pass the exe command with its arguments and it runs the command line as follows in code:
string fileName = "file.txt"; string encryptKey = "encryptKey"; encryptMsg = LaunchEXE.Run(@"c:\program files\network associates\pgpnt\pgp", @" -e " + fileName + " " + encryptKey + " +force", 10);First question, does anybody know if this is a problem due to the Server and the PGP software? I am having trouble getting support as this is a free program.