12 using System.Collections.Generic;
14 using System.ServiceProcess;
18 using System.Configuration.Install;
29 static void Main(
string[] args)
31 bool mutexCreated =
false;
32 System.Threading.Mutex mutex =
new System.Threading.Mutex(
true,
"EaseFilter", out mutexCreated);
38 Console.WriteLine(
"There are another EaseFilter service instance running, can't start the second one.");
44 if (Environment.UserInteractive)
50 string command = args[0];
51 switch (command.ToLower())
53 case "-installdriver":
55 bool ret = FilterAPI.InstallDriver();
59 Console.WriteLine(
"Install driver failed:" + FilterAPI.GetLastErrorMessage());
65 case "-uninstalldriver":
67 FilterAPI.StopFilter();
69 bool ret = FilterAPI.UnInstallDriver();
73 Console.WriteLine(
"UnInstall driver failed:" + FilterAPI.GetLastErrorMessage());
79 case "-installservice":
83 ManagedInstallerClass.InstallHelper(
new string[] { Assembly.GetExecutingAssembly().Location });
87 Console.WriteLine(
"Install service failed:" + ex.Message);
93 case "-uninstallservice":
97 ManagedInstallerClass.InstallHelper(
new string[] {
"/u", Assembly.GetExecutingAssembly().Location });
101 Console.WriteLine(
"UnInstall service failed:" + ex.Message);
111 Console.WriteLine(
"Starting FileMonitor console application...");
116 FilterWorker.StartService();
117 Console.WriteLine(
"\n\nPress any key to stop program");
119 FilterWorker.StopService();
123 Console.WriteLine(
"Start FileMonitor service failed:" + ex.Message);
129 default:
Console.WriteLine(
"The command " + command +
" doesn't exist"); PrintUsage();
break;
142 Console.WriteLine(
"Starting EaseFilter windows service...");
143 EaseFilterService service =
new EaseFilterService();
144 ServiceBase.Run(service);
150 EventManager.WriteMessage(132,
"EaseFilterService",
EventLevel.Error,
"EaseFilter failed with error " + ex.Message);
154 Console.WriteLine(
"Exiting EaseFilter service.");
162 static void PrintUsage()
164 Console.WriteLine(
"Usage: FileMonitorService command");
165 Console.WriteLine(
"Commands:");
166 Console.WriteLine(
"-InstallDriver --Install EaseFilter filter driver.");
167 Console.WriteLine(
"-UninstallDriver --Uninstall EaseFilter filter driver.");
168 Console.WriteLine(
"-InstallService --Install EaseFilter Windows service.");
169 Console.WriteLine(
"-UnInstallService ---Uninstall EaseFilter Windows service.");
170 Console.WriteLine(
"-Console ----start the console application.");
static EventLevel EventLevel
static void CopyOSPlatformDependentFiles()
static EventOutputType EventOutputType