Example #1
0
        // The main entry point for the process
        static void Main(string[] args)
        {
            if (args.Length == 1 && args[0].CompareTo("-debug") == 0)           //run as a console application
            {
                System.Console.WriteLine("Starting WinTunnel as a console application...");
                WinTunnel tunnel = new WinTunnel();
                tunnel.m_debug = true;
                tunnel.OnStart(args);
                return;
            }
            else if (args.Length == 1 && args[0].CompareTo("-remove") == 0)             //remove service
            {
                System.Console.WriteLine("Remove WinTunnel as a service...");
                String argument  = "-u " + Process.GetCurrentProcess().MainModule.ModuleName;
                String launchCmd = RuntimeEnvironment.GetRuntimeDirectory() + "InstallUtil.exe";
                launchProcess(launchCmd, argument);
                return;
            }
            else if (args.Length > 0 && args[0].CompareTo("-install") == 0)              //install as a service
            {
                System.Console.WriteLine("Installing WinTunnel as a service...");

                StringBuilder argument = new StringBuilder();
                int           i        = 1;
                while (i < args.Length)
                {
                    if (args[i].ToLower().CompareTo("-user") == 0)
                    {
                        argument.Append(" /user="******"-password") == 0)
                    {
                        argument.Append(" /password="******" ");
                argument.Append(Process.GetCurrentProcess().MainModule.ModuleName);

                String launchCmd = RuntimeEnvironment.GetRuntimeDirectory() + "InstallUtil.exe";
                launchProcess(launchCmd, argument.ToString());
                return;
            }

            System.ServiceProcess.ServiceBase[] ServicesToRun;
            ServicesToRun = new System.ServiceProcess.ServiceBase[] { new WinTunnel() };
            System.ServiceProcess.ServiceBase.Run(ServicesToRun);
        }
Example #2
0
		// The main entry point for the process
		static void Main(string[] args)
		{
			if (args.Length==1 && args[0].CompareTo("-debug") ==0 ) //run as a console application 
			{
				System.Console.WriteLine("Starting WinTunnel as a console application...");
				WinTunnel tunnel = new WinTunnel();
				tunnel.m_debug = true;
				tunnel.OnStart(args);
				return;
			}
			else if (args.Length == 1 && args[0].CompareTo("-remove") ==0 ) //remove service
			{
				System.Console.WriteLine("Remove WinTunnel as a service...");
				String argument = "-u " + Process.GetCurrentProcess().MainModule.ModuleName;
				String launchCmd = RuntimeEnvironment.GetRuntimeDirectory() + "InstallUtil.exe";
				launchProcess(launchCmd, argument);
				return;
			}
			else if (args.Length  > 0 && args[0].CompareTo("-install") ==0 ) //install as a service
			{
				System.Console.WriteLine("Installing WinTunnel as a service...");
		
				StringBuilder argument = new StringBuilder();
				int i=1;
				while(i < args.Length)
				{
					if (args[i].ToLower().CompareTo("-user") == 0)
					{
						argument.Append(" /user="******"-password") == 0)
					{
						argument.Append(" /password="******" ");
				argument.Append( Process.GetCurrentProcess().MainModule.ModuleName );

				String launchCmd = RuntimeEnvironment.GetRuntimeDirectory() + "InstallUtil.exe";
				launchProcess(launchCmd, argument.ToString());
				return;
			}

			System.ServiceProcess.ServiceBase[] ServicesToRun;
			ServicesToRun = new System.ServiceProcess.ServiceBase[] { new WinTunnel() };
			System.ServiceProcess.ServiceBase.Run(ServicesToRun);
		}