Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I doings some Windows 2000 splunking and have no problem adding entries to the key of interest, but it seems the registry is cached and my changes are not showing up if I open a new cmd.exe window. Can see then in regedit, and if I do a save there, the changes become visible. This leads me to thinking the registry is cached, so how do I flush it?
#!/usr/bin/perl #------------------------------------------------ # Fun with Windows 2000 Registry #------------------------------------------------ use strict; my $Registry; use Win32::TieRegistry ( TiedRef => \$Registry, Delimiter => "/", ArrayValues => 1, SplitMultis => 1, AllowLoad => 1, AllowSave => 1, qw( REG_SZ REG_EXPAND_SZ REG_DWORD REG_BINARY REG_MULTI_SZ KEY_READ KEY_WRITE EY_ALL_ACCESS ), ); my $Environment = $Registry->{"LMachine/System/CurrentControlSet/Contr +ol/Session Manager/Environment"} or die "Can't find the Cuurent Sess +ion Environment: $^E\n"; my $okay = $Environment->SetValue( "CRAP1", '%CDS_INST_DIR%\tools\bin' +, 2);

Replies are listed 'Best First'.
Re: How to flush Windows registry cache
by Moonie (Friar) on Feb 22, 2002 at 01:59 UTC
    Curiousity...did you read the documentation for Win32::TieRegistry? In it, it explicity states:
    Flush( $bFlush ) Flushes all cached information about the Registry key so that future u +ses will get fresh data from the Registry. If the optional $bFlush is specified and a true value, then RegFlushKe +y() will be called, which is almost never necessary.

    - Moon
      Yes I read the docs, and tried using Flush. It did not do anything. Sorry I forgot to mention that. Should I be doing something beyond:
      $Environment->Flush;
      Is $bFlush anything more than a variable that needs to evaluate to true to run RegFlushKey()?