public RemoteEnvironment(string ipAddress, string userName, string password, string psExecPath)
        {
            IpAddress = ipAddress;
              UserName = userName;
              Password = password;
            _psExecPath = psExecPath;

            // wait for ping
              RetryUtility.RetryAction(() =>
            {
              var ping = new Ping();
              var reply = ping.Send(IpAddress);
              OsTestLogger.WriteLine(string.Format("Pinging ip:{0}, reply: {1}", ipAddress, reply.Status));
              if (reply.Status != IPStatus.Success)
            throw new InvalidOperationException(string.Format("Remote IP {0} ping returns {1}", ipAddress, reply.Status));
            }, 50, 5000);

              // give time for the RPC service to start
              RetryUtility.RetryAction(() => { WmiWrapperInstance = new WmiWrapper(ipAddress, userName, password); }, 10, 5000);
              WindowsShellInstance = new WindowsShell(this, psExecPath);
              //this will populate the GuestEnvironmentVariables. Short time after start APPDATA may be empty
              RetryUtility.RetryAction( InvalidateCachedGuestEnvironmentVariables, 10, 10000);

              IsUACEnabled = CheckIsUAC();
        }
Beispiel #2
0
 /// <summary>
 /// Returns Ids and creation time of the direct childs
 /// </summary>
 /// <param name="windowsShell"></param>
 /// <param name="psExecPId"></param>
 /// <returns></returns>
 internal IEnumerable<RemoteProcess> GetChildProcesses(WindowsShell windowsShell, string psExecPId)
 {
     // Query processes
       var childSearcher = new ManagementObjectSearcher(GetScope(), new ObjectQuery("Select * From Win32_Process Where ParentProcessID=" + psExecPId));
       var childProcessQueryCollection = childSearcher.Get();
       //var childPid = childProcessQueryCollection.Cast<ManagementObject>().Select(w => w["ProcessId"]);
       //var CreationDate = childProcessQueryCollection.Cast<ManagementObject>().Select(w => w["CreationDate"]);
       IList<RemoteProcess> list = new List<RemoteProcess>();
       foreach (var process in childProcessQueryCollection)
       {
     string pid = process["ProcessId"].ToString();
     list.Add(new RemoteProcess(windowsShell.Env, pid));
       }
       return list;
 }