2015-04-07: , , PowerShell . .
, New-Item , , GC , script, ( " → DLL...", .)
, New-Item :
$result = New-Item # ...
$result.Handle.Close()
[gc]::Collect() reg unload.
PowerShell, , - GC Debug Release, [gc]::WaitForPendingFinalizers(), , , , . Release , .
SOME_USER:
$path = "HKLM:\TEMP_hive\newkey" # Key we're going to create.
reg load HKLM\TEMP_hive C:\Users\SOME_USER\NTUSER.DAT
$result = New-Item -Path $path
$result.Handle.Close()
[gc]::Collect()
[gc]::WaitForPendingFinalizers() # Optional, and beware of deadlocks! Only seen this needed in Debug mode.
reg unload HKLM\TEMP_hive
, .
:
[gc]::Collect() , script, New-Item. , , , PowerShell ISE, [gc]::Collect(), , , . PowerShell ISE :
$path = "HKLM:\TEMP_hive\differentnewkey" # Key we're going to create.
reg load HKLM\TEMP_hive C:\Users\SOME_USER\NTUSER.DAT
New-Item -Path $path
:
[gc]::Collect()
reg unload HKLM\TEMP_hive
reg unload .
, New-Item , $result, , , $ reg unload . :
$path = "HKLM:\TEMP_hive\thirdnewkey" # Key we're going to create.
reg load HKLM\TEMP_hive C:\Users\SOME_USER\NTUSER.DAT
$result = New-Item -Path $path
:
[gc]::Collect()
reg unload HKLM\TEMP_hive
, $result.Handle.Close().
, , , , ( + , ) - , . , - , .