Ejemplo n.º 1
0
 internal static void Main(string[] args)
 {
     Trace.AutoFlush = true;
     Trace.Listeners.Add(new TextWriterTraceListener("processAsUser.log"));
     Trace.Listeners.Add(new ConsoleTraceListener());
     var options = new Options();
     bool arguments = Parser.Default.ParseArguments(args, options);
     Trace.TraceInformation("Arguments parsed="+arguments);
     if (arguments){
         WindowsIdentity windowsIdentity = WindowsIdentity.GetCurrent();
         Debug.Assert(windowsIdentity != null, "windowsIdentity != null");
         var processAsUser = new ProcessAsUser(options);
         if (windowsIdentity.IsSystem){
             try{
                 Application.Run(new RDClient(processAsUser));
             }
             catch (ObjectDisposedException){
             }
         }
         else{
             throw new NotImplementedException();
         }
     }
     else{
         string message = options.GetUsage();
         Trace.TraceError(message);
         throw new ArgumentException(message);
     }
 }
Ejemplo n.º 2
0
 public RDClient(ProcessAsUser processAsUser)
     : this()
 {
     _processAsUser = processAsUser;
     Load += OnLoad;
     rdp.OnLoginComplete+=RdpOnOnLoginComplete;
 }
Ejemplo n.º 3
0
 static void Main(string[] args)
 {
     if (args.Length != 4)
     {
         throw new ArgumentException("Args count=" + args.Length + "Expected args--> UserName, Passowrd, TestExecutorPath,TestExecutorArgs");
     }
     ProcessAsUser.Launch(args[0], args[1], args[2], args[3]);
 }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            var handle = GetConsoleWindow();

            // Hide
            ShowWindow(handle, SW_HIDE);

            Trace.AutoFlush = true;
            Trace.Listeners.Add(new TextWriterTraceListener("processAsUser.log"));
            Trace.TraceInformation("Hello");
            if (args.Length != 2)
            {
                throw new ArgumentException("Args count=" + args.Length + "Expected args--> ExePath,ExeArgs");
            }

            var registryKey = Registry.LocalMachine.CreateSubKey(@"Software\Xpand\ProcessAsUser");

            if (registryKey != null)
            {
                var userName = (string)registryKey.GetValue("UserName", "");
                Trace.TraceInformation("Username="******"Password");
                if (!string.IsNullOrEmpty(userName) && !string.IsNullOrEmpty(password))
                {
                    ProcessAsUser.Launch(userName, password, args[0], args[1]);
                }
                else
                {
                    Environment.Exit(200);
                }
            }
            else
            {
                Environment.Exit(200);
            }
        }