本文整理汇总了C#中ProcessStartInfo类的典型用法代码示例。如果您正苦于以下问题:C# ProcessStartInfo类的具体用法?C# ProcessStartInfo怎么用?C# ProcessStartInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ProcessStartInfo类属于命名空间,在下文中一共展示了ProcessStartInfo类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Execute
public static bool Execute(ProjectProperties properties, Log log)
{
Console.WriteLine("compiling");
var processSettings = new ProcessStartInfo();
processSettings.FileName = properties.CscPath;
processSettings.Arguments = properties.FormatCscArguments();
log.WriteLine("Executing {0}", processSettings.FileName);
log.WriteLine("Csc Arguments: {0}", processSettings.Arguments);
processSettings.CreateNoWindow = true;
processSettings.RedirectStandardOutput = true;
processSettings.UseShellExecute = false;
Process cscProcess = null;
try
{
cscProcess = Process.Start(processSettings);
}
catch (Win32Exception)
{
Console.WriteLine("ERROR: csc.exe needs to be on the path.");
return false;
}
var output = cscProcess.StandardOutput.ReadToEnd();
log.WriteLine(output);
cscProcess.WaitForExit();
if (output.Contains("error CS")) return false;
return true;
}
开发者ID:dalbanhi,项目名称:corefxlab,代码行数:33,代码来源:dotnet.cs
示例2: Execute
public static int Execute(string fileName, string arguments,
out string output)
{
ProcessStartInfo psi = new ProcessStartInfo();
psi.UseShellExecute = false;
psi.RedirectStandardError = true;
psi.RedirectStandardOutput = true;
psi.RedirectStandardInput = true;
psi.WindowStyle = ProcessWindowStyle.Hidden;
psi.CreateNoWindow = true;
psi.ErrorDialog = false;
psi.FileName = fileName;
psi.Arguments = arguments;
using (Process process = Process.Start(psi))
{
process.StandardInput.Close();
StreamReader sOut = process.StandardOutput;
StreamReader sErr = process.StandardError;
output = sOut.ReadToEnd() + sErr.ReadToEnd();
sOut.Close();
sErr.Close();
process.WaitForExit();
return process.ExitCode;
}
}
开发者ID:ramyD,项目名称:countly-sdk-unity,代码行数:26,代码来源:CountlyPostprocessor.cs
示例3: ExecuteCommand
static void ExecuteCommand(string command)
{
int exitCode;
ProcessStartInfo processInfo;
Process process;
processInfo = new ProcessStartInfo("cmd.exe", "/c " + command);
processInfo.CreateNoWindow = true;
processInfo.UseShellExecute = false;
// *** Redirect the output ***
processInfo.RedirectStandardError = true;
processInfo.RedirectStandardOutput = true;
process = Process.Start(processInfo);
process.WaitForExit();
// *** Read the streams ***
// Warning: This approach can lead to deadlocks, see Edit #2
string output = process.StandardOutput.ReadToEnd();
string error = process.StandardError.ReadToEnd();
exitCode = process.ExitCode;
Console.WriteLine("output>>" + (String.IsNullOrEmpty(output) ? "(none)" : output));
Console.WriteLine("error>>" + (String.IsNullOrEmpty(error) ? "(none)" : error));
Console.WriteLine("ExitCode: " + exitCode.ToString(), "ExecuteCommand");
process.Close();
}
开发者ID:rwc25,项目名称:ProjectEsper,代码行数:28,代码来源:test.cs
示例4: RunPlistBuddyCommand
public static void RunPlistBuddyCommand(string workingDirectory, string arguments)
{
ProcessStartInfo proc = new ProcessStartInfo ("/usr/libexec/PlistBuddy", "Info.plist -c \"" + arguments + "\"");
proc.WorkingDirectory = workingDirectory;
proc.UseShellExecute = false;
Process.Start(proc);
}
开发者ID:Blueteak,项目名称:Unity3D_AppleTVResources,代码行数:7,代码来源:FixUpPListBuildPostProcess.cs
示例5: Main
static void Main()
{
for (;;)
{
var start = DateTime.Now;
var info = new ProcessStartInfo("xbuild") {
RedirectStandardError = true,
UseShellExecute = false,
RedirectStandardOutput = true,
};
var proc = Process.Start(info);
proc.WaitForExit();
if (proc.ExitCode != 0) {
var allerrs = proc.StandardError
.ReadToEnd().Split("\r\n".ToCharArray(), StringSplitOptions.RemoveEmptyEntries)
.Concat(
proc.StandardOutput.ReadToEnd().Split("\r\n".ToCharArray(), StringSplitOptions.RemoveEmptyEntries)
)
.Where(line => line.Contains("error"))
.ToList();
Process.Start("osascript", string.Format("-e 'display notification \"{0}\" with title \"Home CI\"'",
string.Join(" / ", allerrs.Select(line => line.Replace("\"", "\\\"").Replace("'", "`")))));
}
var wait = min_seconds - (int)(DateTime.Now - start).TotalSeconds;
if (wait > 0)
System.Threading.Thread.Sleep(wait * 1000);
}
}
开发者ID:ignacionr,项目名称:homeCI,代码行数:29,代码来源:Program.cs
示例6: Run
public static void Run(string name)
{
if (name.EndsWith("/")) name = name.Substring(0,name.Length-1);
#if UNITY_STANDALONE_OSX || UNITY_EDITOR // Cut "|| UNITY_EDITOR" if you're using windows
if (name.EndsWith(".app"))
{
name = name + "/Contents/MacOS/";
string[] nn = Directory.GetFiles(name);
name = nn[0];
}
ProcessStartInfo startInfo = new ProcessStartInfo( name);
startInfo.UseShellExecute = false;
startInfo.WorkingDirectory = CurrentDir();
Process.Start(startInfo);
#elif UNITY_STANDALONE_WIN // Paste "|| UNITY_EDITOR" if you're using windows
ProcessStartInfo startInfo = new ProcessStartInfo( name);
startInfo.UseShellExecute = true;
startInfo.WorkingDirectory = CurrentDir();
Process.Start(startInfo);
#else
Debug.LogError("Sorry, I can't open a file on this platform");
#endif
GUIUtility.ExitGUI();
}
开发者ID:masteranza,项目名称:Unity-External-File-Launcher,代码行数:29,代码来源:Launcher.cs
示例7: LaunchEmulator
static void LaunchEmulator ()
{
ProcessStartInfo startInfo = new ProcessStartInfo ()
{
WorkingDirectory = Application.dataPath,
FileName = JavaBuildSettings.AndroidSDKPath + "/../../tools/emulator",
Arguments = string.Format (
"-avd {0}",
"OUYA"
),
UseShellExecute = false,
RedirectStandardError = true,
};
Process process = Process.Start (startInfo);
process.Exited += new EventHandler (
(object sender, EventArgs e) =>
{
if (!process.StandardError.EndOfStream)
{
Debug.LogError (
"Android emulator error: " +
process.StandardError.ReadToEnd ()
);
}
}
);
}
开发者ID:NotYours180,项目名称:UnityHacks,代码行数:28,代码来源:AndroidTools.cs
示例8: Main
public static int Main(string[] args)
{
ProcessStartInfo startInfo = new ProcessStartInfo("[EXE]", "[ARGUMENTS] " + GetArguments(args));
startInfo.UseShellExecute = false;
Process process;
try
{
try
{
process = Process.Start(startInfo);
}
catch (Win32Exception ex)
{
if (ex.NativeErrorCode == Win32RequestedOperationRequiresElevation)
{
// UAC handling requires ShellExecute
startInfo.UseShellExecute = true;
process = Process.Start(startInfo);
}
else throw;
}
process.WaitForExit();
}
catch (Win32Exception ex)
{
if (ex.NativeErrorCode == Win32Cancelled) return 100;
else throw;
}
return process.ExitCode;
}
开发者ID:modulexcite,项目名称:0install-win,代码行数:31,代码来源:stub.template.cs
示例9: GetMXServers
public IList<MXServer> GetMXServers(string domainName)
{
string command = "nslookup -q=mx " + domainName;
ProcessStartInfo procStartInfo = new ProcessStartInfo("cmd", "/c " + command);
procStartInfo.RedirectStandardOutput = true;
procStartInfo.UseShellExecute = false;
procStartInfo.CreateNoWindow = true;
Process proc = new Process();
proc.StartInfo = procStartInfo;
proc.Start();
string result = proc.StandardOutput.ReadToEnd();
if (!string.IsNullOrEmpty(result))
result = result.Replace("\r\n", Environment.NewLine);
IList<MXServer> list = new List<MXServer>();
foreach (string line in result.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries))
{
if (line.Contains("MX preference =") && line.Contains("mail exchanger ="))
{
MXServer mxServer = new MXServer();
mxServer.Preference = Int(GetStringBetween(line, "MX preference = ", ","));
mxServer.MailExchanger = GetStringFrom(line, "mail exchanger = ");
list.Add(mxServer);
}
}
return list.OrderBy(m => m.Preference).ToList();
}
开发者ID:phonglam29305,项目名称:FAMail,代码行数:32,代码来源:Commander.cs
示例10: CallProcess
static bool CallProcess(string processName, string param)
{
ProcessStartInfo process = new ProcessStartInfo
{
CreateNoWindow = false,
UseShellExecute = false,
RedirectStandardError = true,
RedirectStandardOutput = true,
FileName = processName,
Arguments = param,
};
UnityEngine.Debug.Log(processName + " " + param);
Process p = Process.Start(process);
p.StandardOutput.ReadToEnd();
p.WaitForExit();
string error = p.StandardError.ReadToEnd();
if (!string.IsNullOrEmpty(error))
{
UnityEngine.Debug.LogError(processName + " " + param + " ERROR! " + "\n" + error);
string output = p.StandardOutput.ReadToEnd();
if (!string.IsNullOrEmpty(output))
{
UnityEngine.Debug.Log(output);
}
return false;
}
return true;
}
开发者ID:laijingfeng,项目名称:explorer_editor,代码行数:32,代码来源:TablePacker.cs
示例11: Main
static int Main (string [] args)
{
string runtimeEngine = null;
if (args.Length == 0)
return 1;
if (args.Length > 1 && args [1].Length > 0)
runtimeEngine = args [1];
if (args [0] == "nested")
return 0;
string program = Path.Combine (AppDomain.CurrentDomain.BaseDirectory,
"test.exe");
ProcessStartInfo pinfo = null;
if (runtimeEngine != null) {
pinfo = new ProcessStartInfo (runtimeEngine, "\"" + program + "\" nested");
} else {
pinfo = new ProcessStartInfo (program, "nested");
}
pinfo.UseShellExecute = false;
pinfo.RedirectStandardInput = true;
pinfo.RedirectStandardOutput = true;
Process p = Process.Start (pinfo);
if (p.StandardOutput.CurrentEncoding.BodyName != Console.OutputEncoding.BodyName) {
return 2;
}
if (p.StandardInput.Encoding.BodyName != Console.InputEncoding.BodyName)
return 3;
return 0;
}
开发者ID:mono,项目名称:gert,代码行数:35,代码来源:test.cs
示例12: GetCustomerMac
//这里是关键函数了
public string GetCustomerMac(string IP)
{
string dirResults = "";
ProcessStartInfo psi = new ProcessStartInfo();
Process proc = new Process();
psi.FileName = "nbtstat";
psi.RedirectStandardInput = false;
psi.RedirectStandardOutput = true;
psi.Arguments = "-a " + IP;
psi.UseShellExecute = false;
proc = Process.Start(psi);
dirResults = proc.StandardOutput.ReadToEnd();
proc.WaitForExit();
//匹配mac地址
Match m = Regex.Match(dirResults, "\\w+\\-\\w+\\-\\w+\\-\\w+\\-\\w+\\-\\w\\w");
//若匹配成功则返回mac,否则返回找不到主机信息
if (m.ToString() != "")
{
return m.ToString();
}
else
{
return "找不到主机信息";
}
}
开发者ID:xy19xiaoyu,项目名称:TG,代码行数:28,代码来源:Default.aspx.cs
示例13: GetPrefKeysMac
private void GetPrefKeysMac()
{
string homePath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
string pListPath = homePath +"/Library/Preferences/unity." + PlayerSettings.companyName + "." +
PlayerSettings.productName + ".plist";
// Convert from binary plist to xml.
Process p = new Process();
ProcessStartInfo psi = new ProcessStartInfo("plutil", "-convert xml1 \"" + pListPath + "\"");
p.StartInfo = psi;
p.Start();
p.WaitForExit();
StreamReader sr = new StreamReader(pListPath);
string pListData = sr.ReadToEnd();
XmlDocument xml = new XmlDocument();
xml.LoadXml(pListData);
XmlElement plist = xml["plist"];
if (plist == null) return;
XmlNode node = plist["dict"].FirstChild;
while (node != null) {
string name = node.InnerText;
node = node.NextSibling;
PlayerPrefStore pref = new PlayerPrefStore(name, node.Name, node.InnerText);
node = node.NextSibling;
playerPrefs.Add(pref);
}
// // Convert plist back to binary
Process.Start("plutil", " -convert binary1 \"" + pListPath + "\"");
}
开发者ID:BJarv,项目名称:UrsaMajor,代码行数:32,代码来源:PlayerPrefsEditor.cs
示例14: CaptureScreen
private IEnumerator CaptureScreen(string path)
{
// Wait till the last possible moment before screen rendering to hide the UI
yield return null;
GameObject.Find("ScreenShotCanvas").GetComponent<Canvas>().enabled = false;
path = "\"" + path + "\"";
ProcessStartInfo startInfo = new ProcessStartInfo()
{
FileName = "screencapture",
Arguments = path,
};
Process proc = new Process()
{
StartInfo = startInfo,
};
// Wait for screen rendering to complete
yield return new WaitForEndOfFrame ();
proc.Start();
// wait for the process to end
yield return new WaitForEndOfFrame ();
yield return new WaitForEndOfFrame ();
hasNewScreenShot = true;
GameObject.Find("ScreenShotCanvas").GetComponent<Canvas>().enabled = true;
}
开发者ID:Sushisushi-sandesu,项目名称:sushi,代码行数:32,代码来源:ScreenShotScript.cs
示例15: LaunchAdapter
private static Process LaunchAdapter(int adaptee, int adapted)
{
var temp = Path.GetTempFileName() + ".ensimea.exe";
File.Copy(@"%SCRIPTS_HOME%\ensimea.exe".Expand(), temp);
var psi = new ProcessStartInfo();
psi.FileName = temp;
psi.Arguments = String.Format("{0} {1}", adaptee, adapted);
psi.UseShellExecute = false;
psi.RedirectStandardOutput = true;
psi.RedirectStandardError = true;
var p = new Process();
p.StartInfo = psi;
p.OutputDataReceived += (sender, args) => { if (args.Data != null) Console.WriteLine(args.Data); };
p.ErrorDataReceived += (sender, args) => { if (args.Data != null) Console.WriteLine(args.Data); };
if (p.Start()) {
p.BeginOutputReadLine();
p.BeginErrorReadLine();
return p;
} else {
return null;
}
}
开发者ID:xeno-by,项目名称:dotwindows,代码行数:25,代码来源:ensime.cs
示例16: RunCommand
public static string[] RunCommand( string cmd, string arguments )
{
ProcessStartInfo startInfo;
Process p;
StringBuilder result = new StringBuilder();
startInfo = new ProcessStartInfo(cmd, arguments);
startInfo.WorkingDirectory = Environment.CurrentDirectory;
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.CreateNoWindow = true;
startInfo.ErrorDialog = false;
startInfo.RedirectStandardError = false;
startInfo.RedirectStandardInput = false;
startInfo.RedirectStandardOutput = true;
startInfo.UseShellExecute = false;
p = Process.Start(startInfo);
using (StreamReader o = p.StandardOutput) {
//while (!o.EndOfStream) {
result.Append(o.ReadToEnd());
//}
}
return result.ToString().Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);
}
开发者ID:kodybrown,项目名称:gitstatus,代码行数:26,代码来源:git.cs
示例17: Main
public static void Main(string[] args)
{
try
{
if (args.Length == 0 || args[0].ToLower() == "-?" || args[0].ToLower() == "/?")
{
Console.WriteLine(usage);
}
else
{
ProcessStartInfo psi = new ProcessStartInfo(args[0]);
Console.Write(@"User Name [domain\user]: ");
string[] userParts = Console.ReadLine().Split('\\');
if (userParts.Length == 2)
{
psi.Domain = userParts[0];
psi.UserName = userParts[1];
}
else
psi.UserName = userParts[0];
psi.Password = ReadPassword();
psi.UseShellExecute = false;
for (int i = 1; i < args.Length; i++)
psi.Arguments += (i == 1 ? "\"" : " \"") + args[i] + "\"";
Process.Start(psi);
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
开发者ID:Diullei,项目名称:Storm,代码行数:35,代码来源:runas.cs
示例18: Main
public static void Main(string[] args)
{
if (args.Length < 4) {
Console.WriteLine ("Usage : ./benchmarks-analyzer.exe mode mono1 mono2 benchmarker-folder");
Console.WriteLine (" mode : majors for the two monos [s|c|cp]v[s|c|cp]");
Console.WriteLine (" mono2 : if mono2 is '-' then mono1 is used for both runs");
return;
}
int arg = 0;
string mode = args [arg++];
string mono1 = args [arg++];
string mono2 = args [arg++];
string analyzer = "analyzer.exe";
string benchmarker_folder = args [arg++];
string benchmarks_folder = Path.Combine (benchmarker_folder, "benchmarks");
string tests_folder = Path.Combine (benchmarker_folder, "tests");
List<Benchmark> benchmark_list = Benchmark.LoadAllFrom (benchmarks_folder);
foreach (Benchmark b in benchmark_list) {
ProcessStartInfo info = new ProcessStartInfo {
UseShellExecute = false,
};
info.FileName = analyzer;
info.Arguments = mode + " " + mono1 + " " + mono2 + " " + Path.Combine (tests_folder, b.TestDirectory) + " " + string.Join (" ", b.CommandLine);
Console.WriteLine ("{0}", b.Name);
Process ps = Process.Start (info);
ps.WaitForExit ();
}
}
开发者ID:BrzVlad,项目名称:mono-memory-tool,代码行数:33,代码来源:BenchmarksAnalyzer.cs
示例19: RestartElevated
/// <summary>
/// Restart the current process with administrator credentials
/// </summary>
internal static void RestartElevated()
{
ProcessStartInfo startInfo = new ProcessStartInfo();
string arguments = "";
string[] args = Environment.GetCommandLineArgs();
for(int i = 1; i < args.Length; i++ )
arguments +="\""+args[i]+"\" ";
startInfo.Arguments = arguments.TrimEnd();
startInfo.UseShellExecute = true;
startInfo.WorkingDirectory = Environment.CurrentDirectory;
startInfo.FileName = Application.ExecutablePath;
startInfo.Verb = "runas";
try
{
Process p = Process.Start(startInfo);
}
catch (System.ComponentModel.Win32Exception)
{
return; //If cancelled, do nothing
}
Application.Exit();
}
开发者ID:oleg-shilo,项目名称:cs-script,代码行数:28,代码来源:VistaSecurity.cs
示例20: btnScan_Click
protected void btnScan_Click(object sender, EventArgs e)
{
try
{
string switches = " /inventory /startaddress:" + txt_range_from.Text + " /endaddress:" + txt_range_to.Text + " /computers:no /devices:yes /community:" + txt_community.Text;
ProcessStartInfo info = new ProcessStartInfo(Server.MapPath("~/binaries/Admin.exe"), switches);
Process pro = new Process();
pro.StartInfo = info;
pro.Start();
pro.WaitForExit();
// lbl_status.Text = "Scanning completed...";
txt_community.Text = "";
txt_range_from.Text = "";
txt_range_to.Text = "";
string myScript;
myScript = "<script language=javascript>alert('Scanning completed successfully...');</script>";
Page.RegisterClientScriptBlock("MyScript", myScript);
// return;
}
catch (Exception ex)
{
string myScript;
myScript = "<script language=javascript>alert('Exception - '" + ex + "');</script>";
Page.RegisterClientScriptBlock("MyScript", myScript);
return;
}
}
开发者ID:progressiveinfotech,项目名称:PRO_FY13_40_Helpdesk-Support-and-Customization_EIH,代码行数:28,代码来源:Network_Discovery.aspx.cs
注:本文中的ProcessStartInfo类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论