本文整理汇总了C#中System.Diagnostics.Process.Start方法的典型用法代码示例。如果您正苦于以下问题:C# System.Diagnostics.Process.Start方法的具体用法?C# System.Diagnostics.Process.Start怎么用?C# System.Diagnostics.Process.Start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Diagnostics.Process
的用法示例。
在下文中一共展示了System.Diagnostics.Process.Start方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: run_shell_script
private static void run_shell_script()
{
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.EnableRaisingEvents = false;
proc.StartInfo.FileName = "run.sh";
proc.Start();
}
示例2: CopyFolder
//-------------------------------------------------------------------//
//add
public void CopyFolder(DirectoryInfo source, DirectoryInfo target)
{
try
{
System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
startInfo.FileName = "cmd.exe";
if (!(Directory.Exists(target.FullName)))
{
startInfo.Arguments = "/C md " + target.FullName;
process.StartInfo = startInfo;
process.Start();
process.WaitForExit();
}
string cmd = "/c xcopy ";
startInfo.Arguments = cmd + source.FullName + " " + target.FullName + " /e /y";
process.StartInfo = startInfo;
process.Start();
process.WaitForExit();
}
catch (Exception e)
{
string[] temp = e.ToString().Split('\'');
string ex = temp[0] + "\n" + temp[1];
temp = ex.Split(new string[] { ": " }, StringSplitOptions.None);
MessageBox.Show("" + temp[1]);
}
}
示例3: start
public void start()
{
try
{
geoDatabaseUtility geoUtil = new geoDatabaseUtility();
System.Diagnostics.Process pr = new System.Diagnostics.Process();
geoUtil.check_dir(rmrsDir);
string hFl = rmrsDir + "\\" + HelpFileName;
pr.StartInfo.FileName = hFl;
if (System.IO.File.Exists(hFl))
{
pr.Start();
}
else
{
update up = new update();
try
{
System.Windows.Forms.MessageBox.Show("Can't find help files. Trying to download from the internet.");
string cuSet = up.UpdateCheck;
if (cuSet.ToLower() != "yes")
{
up.UpdateCheck = "yes";
}
Properties.Settings.Default.HelpVersion = "unknown";
Properties.Settings.Default.Save();
if (up.updateHelp())
{
pr.Start();
}
else
{
System.Windows.Forms.MessageBox.Show("Can't find help files on the internet. Try again later.");
}
up.UpdateCheck = cuSet;
}
catch
{
System.Windows.Forms.MessageBox.Show("Error in updating help. Try again later.");
}
}
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
finally
{
}
}
示例4: Chmod
public static void Chmod(string Filename, int Chmod)
{
string exec = "chmod "+ Chmod.ToString() +" \""+ Filename +"\"";
System.Diagnostics.Process process = new System.Diagnostics.Process();
process.StartInfo.FileName = exec;
process.Start();
}
示例5: runningBalkCopy
public static void runningBalkCopy(string dbName, string path, BCPDirection direction, string option, string remoteDb)
{
//ディレクション
string strDirection = "in";
if (direction == BCPDirection.BCP_OUT)
{
strDirection = "out";
}
else
{
strDirection = "in";
}
//リモートDB
string strRemoteDb = "";
if (remoteDb != "")
{
strRemoteDb = " -S " + remoteDb;
}
using (System.Diagnostics.Process proc = new System.Diagnostics.Process())
{
proc.StartInfo.FileName = "bcp";
proc.StartInfo.Arguments = dbName + " " + strDirection + " \"" + path + "\" " + option + strRemoteDb;
proc.Start();
proc.WaitForExit();
}
}
示例6: CheckEpub
//CheckEpubを実施、Output/Errorを表示する
public void CheckEpub()
{
//EPUBチェック実施中パネルを表示する
var checkingDlg = new EpubCheckingDialog();
checkingDlg.Show();
var p = new System.Diagnostics.Process();
//実行ファイル
p.StartInfo.FileName = javaPath;
//引数
var args = "-jar "
+ "\""+ epubCheckPath + "\" "
+" \"" + epubPath + "\"";
p.StartInfo.Arguments = args;
//出力とエラーをストリームに書き込むようにする
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
//OutputDataReceivedとErrorDataReceivedイベントハンドラを追加
p.OutputDataReceived += OutputDataReceived;
p.ErrorDataReceived += ErrorDataReceived;
p.StartInfo.RedirectStandardInput = false;
p.StartInfo.CreateNoWindow = true;
p.Start();
p.BeginOutputReadLine();
p.BeginErrorReadLine();
p.WaitForExit();
p.Close();
var resultDlg = new EpubCheckResultDialog();
//Outputをコピーする
foreach (var output in outputLines)
{
resultDlg.outputTextBox.Text += (output + "\n");
}
//Errorをコピーする
if (errorLines.Count> 1)
{
foreach (var error in errorLines)
{
resultDlg.errorTextBox.Text += (error + "\n");
}
}
else
{
resultDlg.errorTextBox.Text = "エラーはありませんでした。";
}
checkingDlg.Close();
resultDlg.ShowDialog();
}
示例7: Install
public override void Install(IDictionary state)
{
// Устанавливаем драйвер.
System.Diagnostics.Process infSetup =
new System.Diagnostics.Process();
infSetup.StartInfo.FileName = "rundll32";
infSetup.StartInfo.Arguments = "syssetup,SetupInfObjectInstallAction DefaultInstall 128 .\\ytdrv.inf";
infSetup.StartInfo.CreateNoWindow = true;
infSetup.StartInfo.UseShellExecute = false;
infSetup.StartInfo.WorkingDirectory = Context.Parameters["INSTDIR"];
infSetup.Start();
base.Install(state);
/*
bool rebootRequired;
int result = Interop.DriverPackageInstallW(
Context.Parameters["INSTDIR"] + "ytdrv.inf",
Interop.DRIVER_PACKAGE_LEGACY_MODE,
IntPtr.Zero,
out rebootRequired
);
MessageBox.Show(result.ToString("X"));
//InstallFirewallRule(state);
*/
}
示例8: Uninstall
public override void Uninstall(IDictionary state)
{
//UninstallFirewallRule(state);
/*
bool rebootRequired;
Interop.DriverPackageUninstallW(
Context.Parameters["TARGETDIR"] + @"\ytdrv.inf",
0,
IntPtr.Zero,
out rebootRequired
);
*/
// Удаляем драйвер.
System.Diagnostics.Process infSetup =
new System.Diagnostics.Process();
infSetup.StartInfo.FileName = "rundll32";
infSetup.StartInfo.Arguments =
"advpack.dll, LaunchINFSection .\\ytdrv.inf,Uninstall.NT";
infSetup.StartInfo.CreateNoWindow = true;
infSetup.StartInfo.UseShellExecute = true;
infSetup.StartInfo.WorkingDirectory = Context.Parameters["INSTDIR"];
infSetup.Start();
base.Uninstall(state);
}
示例9: Command
public void Command(String Action, String Data)
{
iHandle = Win32.FindWindow("WMPlayerApp", "Windows Media Player");
switch (Action)
{
case "Play":
{
if (iHandle == 0)
{
string FileName = @"wmplayer.exe";
System.Diagnostics.Process myProcess = new System.Diagnostics.Process();
myProcess.StartInfo.FileName = FileName;
myProcess.Start();
}
Win32.SendMessage(iHandle, Win32.WM_COMMAND, 0x00004978, 0x00000000);
break;
}
case "Stop":
{
if (iHandle == 0)
return;
Win32.SendMessage(iHandle, Win32.WM_COMMAND, 0x00004979, 0x00000000);
break;
}
}
}
示例10: iv_MouseClick
private void iv_MouseClick(object sender, MouseEventArgs e)
{
string filename = ((ImageViewerControl)(sender)).FileName;
System.Diagnostics.Process process = new System.Diagnostics.Process();
process.StartInfo = new System.Diagnostics.ProcessStartInfo(filename);
process.Start();
}
示例11: ExecuteCommand
private static string ExecuteCommand(string fileName, string arguments)
{
try
{
System.Diagnostics.Process process = new System.Diagnostics.Process();
process.StartInfo = new System.Diagnostics.ProcessStartInfo()
{
FileName = fileName,
Arguments = arguments,
WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden,
CreateNoWindow = true,
UseShellExecute = false,
RedirectStandardError = true
};
process.Start();
string error = process.StandardError.ReadToEnd();
process.WaitForExit();
return error;
}
catch (Exception e)
{
return e.Message;
}
}
示例12: device_OnPaketArrival
static void device_OnPaketArrival(object sender, CaptureEventArgs e)
{
Packet packet = Packet.ParsePacket(e.Packet.LinkLayerType, e.Packet.Data);
var tcpPacket = TcpPacket.GetEncapsulated(packet);
// TcpPacket tcpPacket = packet.Extract(typeof(TcpPacket)) as TcpPacket;
//string KeyWord = "qwe";
if (tcpPacket != null) {
String SPort = tcpPacket.SourcePort.ToString();
var DPort = tcpPacket.DestinationPort.ToString();
var Data = Encoding.Unicode.GetString(tcpPacket.PayloadData); //Encoding.ASCII.GetString(tcpPacket.PayloadData).ToString();
if (OptionTCP.UnsafeCompareByte(tcpPacket.PayloadData, KeyWord))
{ //if if (OptionTCP.UnsafeCompareByte(tcpPacket.PayloadData, KeyWord) && SPort = tcpPacket.SourcePort.ToString() == 1768)
Console.WriteLine("eeeeeeeess");
try
{
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo.FileName = "dropTcpPacket.exe";
proc.StartInfo.Arguments = StegWord;
proc.Start();
}
catch (Exception exp) {
Console.WriteLine("errro .. {0}", exp.ToString());
}
}
else Console.WriteLine("nnnnnnnnoo: {0}", Encoding.Unicode.GetString(KeyWord));
Console.WriteLine("Sport: {0}, DPort: {1}, Data: {2}", SPort, DPort, Data);
Console.WriteLine("==========================================================");
}
}
示例13: Execute
//function to run an exe with a given set of arguments
public static bool Execute(string executable, string[] args)
{
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo.WorkingDirectory = ".";
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.FileName = executable;
//convert string[] to string for the process
string arg = "";
if((args != null) && args.Length >= 1)
arg = args[0];
for (int i = 1; i < args.Length; i++)
arg = arg + " " + args[i];
proc.StartInfo.Arguments = arg;
bool ret = false;
try
{
ret = proc.Start();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
throw ex;
}
return ret;
}
示例14: runRegisterScript
bool runRegisterScript()
{
using (System.Diagnostics.Process p = new System.Diagnostics.Process())
{
System.Diagnostics.ProcessStartInfo info = new System.Diagnostics.ProcessStartInfo(@"ruby");
info.Arguments = "C:\\Users\\Saulo\\Documents\\RPGVXAce\\projectNOMAD\\Scripts\\register.rb"+name+" "+email+" "+ username + " " + password; // set args
info.RedirectStandardInput = true;
info.RedirectStandardOutput = true;
info.UseShellExecute = false;
p.StartInfo = info;
p.Start();
String output = p.StandardOutput.ReadToEnd();
// process output
if (output == "0")
{
MessageBox.Show("An error occoured, please try again");
return false;
}
else
{
MessageBox.Show("Account Successfully created");
return true;
}
}
}
示例15: GetMacAddress
public static string GetMacAddress(string ipAddress)
{
string macAddress = string.Empty;
System.Diagnostics.Process pProcess = new System.Diagnostics.Process();
pProcess.StartInfo.FileName = "arp";
pProcess.StartInfo.Arguments = "-a " + ipAddress;
pProcess.StartInfo.UseShellExecute = false;
pProcess.StartInfo.RedirectStandardOutput = true;
pProcess.StartInfo.CreateNoWindow = true;
pProcess.Start();
string strOutput = pProcess.StandardOutput.ReadToEnd();
string[] substrings = strOutput.Split('-');
if (substrings.Length >= 8)
{
macAddress = substrings[3].Substring(Math.Max(0, substrings[3].Length - 2))
+ "-" + substrings[4] + "-" + substrings[5] + "-" + substrings[6]
+ "-" + substrings[7] + "-"
+ substrings[8].Substring(0, 2);
return macAddress;
}
else
{
return "not found";
}
}