using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace SecurityRight
{
static class Program
{
/// <summary>
/// 應用程式的主要進入點。
/// </summary>
[STAThread]
static void Main()
{
//只能是應用程式名稱,不能加入副檔名
Process[] x = Process.GetProcessesByName("LINE");
if (x.Length <= 0)
{
MessageBox.Show("沒有");
}
else
{
MessageBox.Show("有");
}
System.Diagnostics.Process[] p1 = System.Diagnostics.Process.GetProcesses();
foreach (System.Diagnostics.Process pro in p1)
{
//只能是應用程式名稱,不能加入副檔名
if (pro.ProcessName.ToUpper().Contains("LINE"))
{
MessageBox.Show("有了");
//U r Operations
}
};
if (p1.Length <= 0)
{
// string sDir = @"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System";
// object v = Registry.GetValue(sDir, "EnableLUA", RegistryValueKind.DWord);
// if (v.ToString() == "1")
// {
// string str = "";
// if (Directory.Exists(@"C:\Program Files (x86)\APM\APMS Client\Log"))
// str = @"C:\Program Files (x86)\APM\APMS Client\SecurityFile.exe";
// if (Directory.Exists(@"C:\Program Files\APM\APMS Client\Log"))
// str = @"C:\Program Files\APM\APMS Client\SecurityFile.exe";
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName = "cmd.exe";
//if (Directory.Exists(@"C:\Program Files (x86)\APM\APMS Client\Log"))
// p.StartInfo.Arguments = @"/k cd\Program Files (x86)\APM\APMS Client\";
//if (Directory.Exists(@"C:\Program Files\APM\APMS Client\Log"))
// p.StartInfo.Arguments = @"/k cd\Program Files\APM\APMS Client\";
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.CreateNoWindow = true;
p.Start();
p.StandardInput.WriteLine("C:");
//if (Directory.Exists(@"C:\Program Files (x86)\APM\APMS Client\Log"))
// p.StandardInput.WriteLine(@"cd\Program Files (x86)\APM\APMS Client");
//if (Directory.Exists(@"C:\Program Files\APM\APMS Client\Log"))
// p.StandardInput.WriteLine(@"cd\Program Files\APM\APMS Client");
//判斷是否存在資料匣
if (Directory.Exists(@"C:\Users\tony777\AppData\Local\LINE\bin"))
p.StandardInput.WriteLine(@"C:\Users\tony777\AppData\Local\LINE\bin\LineLauncher.exe");
else
{
// p.StandardInput.WriteLine(@"C:\Users\tony777\AppData\Local\LINE\bin\LineLauncher.exe");
}
p.StandardInput.WriteLine("exit");
p.WaitForExit();
p.Close();
// }
}
Application.Exit();
}
}
}
沒有留言:
張貼留言