Created
April 4, 2011 14:51
-
-
Save jptoto/901763 to your computer and use it in GitHub Desktop.
Start a windows process / .exe
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FileImporter { | |
public void RunImport() { | |
bool wait = true; | |
string exec = ConfigurationManager.AppSettings["Executable"]; | |
string switches = ConfigurationManager.AppSettings["Switches"]; | |
string parameters = ConfigurationManager.AppSettings["Params"]; | |
string startDirectory = ConfigurationManager.AppSettings["StartDirectory"]; | |
ILogger logger = new EventLogger(); | |
try | |
{ | |
Process proc = new Process(); | |
proc.StartInfo.FileName = exec; | |
proc.StartInfo.Arguments = switches + " \"" + parameters + "\""; | |
proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; | |
proc.StartInfo.CreateNoWindow = true; | |
proc.StartInfo.UseShellExecute = false; | |
proc.StartInfo.RedirectStandardError = true; | |
proc.StartInfo.RedirectStandardOutput = true; | |
proc.StartInfo.WorkingDirectory = startDirectory; | |
proc.Start(); | |
} | |
catch (Exception ex) | |
{ | |
logger.Error("Failed to execute Import Package.", ex.InnerException); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment