This repository was archived by the owner on Jan 23, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +33
-1
lines changed
src/System.Diagnostics.Process Expand file tree Collapse file tree 2 files changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -205,7 +205,14 @@ internal PerformanceMonitor(string machineName)
205205 private void Init ( )
206206 {
207207#if FEATURE_REGISTRY
208- _perfDataKey = Registry . PerformanceData ;
208+ if ( ProcessManager . IsRemoteMachine ( _machineName ) )
209+ {
210+ _perfDataKey = RegistryKey . OpenRemoteBaseKey ( RegistryHive . PerformanceData , _machineName ) ;
211+ }
212+ else
213+ {
214+ _perfDataKey = Registry . PerformanceData ;
215+ }
209216#endif
210217 }
211218
Original file line number Diff line number Diff line change 44
55using System . Collections . Generic ;
66using System . ComponentModel ;
7+ using System . DirectoryServices . ActiveDirectory ;
78using System . IO ;
89using System . Linq ;
910using System . Net ;
@@ -920,6 +921,30 @@ public void GetProcesses_EmptyMachineName_ThrowsArgumentException()
920921 AssertExtensions . Throws < ArgumentException > ( null , ( ) => Process . GetProcesses ( "" ) ) ;
921922 }
922923
924+ [ Fact ]
925+ public void GetProcesses_InvalidMachineName_ThrowsInvalidOperationException ( )
926+ {
927+ Assert . Throws < InvalidOperationException > ( ( ) => Process . GetProcesses ( Guid . NewGuid ( ) . ToString ( ) ) ) ;
928+ }
929+
930+ [ Fact ]
931+ public void GetProcesses_RemoteMachinePath_ReturnsExpected ( )
932+ {
933+ try
934+ {
935+ Process [ ] processes = Process . GetProcesses ( Environment . MachineName + "." + Domain . GetComputerDomain ( ) ) ;
936+ Assert . NotEmpty ( processes ) ;
937+ }
938+ catch ( ActiveDirectoryObjectNotFoundException )
939+ {
940+ //This will be thrown when the executing machine is not domain-joined, i.e. in CI
941+ }
942+ catch ( PlatformNotSupportedException )
943+ {
944+ //System.DirectoryServices is not supported on all platforms
945+ }
946+ }
947+
923948 [ Fact ]
924949 [ SkipOnTargetFramework ( TargetFrameworkMonikers . Uap , "Retrieving information about local processes is not supported on uap" ) ]
925950 public void GetProcessesByName_ProcessName_ReturnsExpected ( )
You can’t perform that action at this time.
0 commit comments