Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - registry caching/protecting

Reply
 
Old 03-12-2009   #1 (permalink)
Dan


 
 

registry caching/protecting

Hi all,
I have a little script to read a registry value using WMI:


Const HKEY_LOCAL_MACHINE = &H80000002

Set StdOut = WScript.StdOut
Set objReg =
GetObject("winmgmts:{impersonationLevel=impersonate,authenticationLevel=Pkt}!\\.\root\default:StdRegProv")

strKeyPath = "SOFTWARE\Microsoft\MSSQLServer\MSSQLServer\CurrentVersion"
strValueName = "CurrentVersion"
lStatus = objReg.GetStringValue
(HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue)

StdOut.WriteLine "Status: " & lStatus
StdOut.WriteLine "Value: " & strValue
Set objReg = Nothing

Running on a Win 2003 R2 x64 SP2 the output looks like:
Status: 0
Value: 10.0.1600.22

So far so good.

If i now open regedit and rename the registry value let's say to
"OldVersion" without changing the script, rerunning the script still shows to
above result ????
Is there any registry caching or registry protecting going on and how to
prevent this from happen ??

TIA
acki

Little ad on info:
Running this script on a vista ent. (with sql server installed to have the
requested regkeys) the script act as expected (error after renaming regkey
with regedit) ???



My System SpecsSystem Spec
Old 03-12-2009   #2 (permalink)
Pegasus [MVP]


 
 

Re: registry caching/protecting


"Dan" <Dan@xxxxxx> wrote in message
news:7870CA45-42F7-402C-81C5-C1991D5259F3@xxxxxx
Quote:

> Hi all,
> I have a little script to read a registry value using WMI:
>
>
> Const HKEY_LOCAL_MACHINE = &H80000002
>
> Set StdOut = WScript.StdOut
> Set objReg =
> GetObject("winmgmts:{impersonationLevel=impersonate,authenticationLevel=Pkt}!\\.\root\default:StdRegProv")
>
> strKeyPath = "SOFTWARE\Microsoft\MSSQLServer\MSSQLServer\CurrentVersion"
> strValueName = "CurrentVersion"
> lStatus = objReg.GetStringValue
> (HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue)
>
> StdOut.WriteLine "Status: " & lStatus
> StdOut.WriteLine "Value: " & strValue
> Set objReg = Nothing
>
> Running on a Win 2003 R2 x64 SP2 the output looks like:
> Status: 0
> Value: 10.0.1600.22
>
> So far so good.
>
> If i now open regedit and rename the registry value let's say to
> "OldVersion" without changing the script, rerunning the script still shows
> to
> above result ????
> Is there any registry caching or registry protecting going on and how to
> prevent this from happen ??
>
> TIA
> acki
>
> Little ad on info:
> Running this script on a vista ent. (with sql server installed to have the
> requested regkeys) the script act as expected (error after renaming regkey
> with regedit) ???
When I ran your script on my WinXP machine then it behaved as expected.
Renaming the value "CurrentVersion" to "OldVersion" caused the script to
return a blank. Perhaps you were renaming the wrong value. Note also that
your line [StdOut.WriteLine "Value: " & strValue] contains a misnomer.
You're not returning a registry "value" but the "value data" for the value
name "CurrentVersion".


My System SpecsSystem Spec
Old 03-12-2009   #3 (permalink)
Dan


 
 

Re: registry caching/protecting

Pegasus,
The problem is only on win2k3 x64 systems

The script returns the data from
HKLM\SOFTWARE\Wow6432Node\Microsoft\MSSQLServer\MSSQLServer\CurrentVersion

and not from
HKLM\SOFTWARE\Microsoft\MSSQLServer\MSSQLServer\CurrentVersion

so renameing in the second hive does not change the script output...
Thx for your quick response anyway.



I'm sure not renaming wrong key as it only exists (
"Pegasus [MVP]" wrote:
Quote:

>
> "Dan" <Dan@xxxxxx> wrote in message
> news:7870CA45-42F7-402C-81C5-C1991D5259F3@xxxxxx
Quote:

> > Hi all,
> > I have a little script to read a registry value using WMI:
> >
> >
> > Const HKEY_LOCAL_MACHINE = &H80000002
> >
> > Set StdOut = WScript.StdOut
> > Set objReg =
> > GetObject("winmgmts:{impersonationLevel=impersonate,authenticationLevel=Pkt}!\\.\root\default:StdRegProv")
> >
> > strKeyPath = "SOFTWARE\Microsoft\MSSQLServer\MSSQLServer\CurrentVersion"
> > strValueName = "CurrentVersion"
> > lStatus = objReg.GetStringValue
> > (HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue)
> >
> > StdOut.WriteLine "Status: " & lStatus
> > StdOut.WriteLine "Value: " & strValue
> > Set objReg = Nothing
> >
> > Running on a Win 2003 R2 x64 SP2 the output looks like:
> > Status: 0
> > Value: 10.0.1600.22
> >
> > So far so good.
> >
> > If i now open regedit and rename the registry value let's say to
> > "OldVersion" without changing the script, rerunning the script still shows
> > to
> > above result ????
> > Is there any registry caching or registry protecting going on and how to
> > prevent this from happen ??
> >
> > TIA
> > acki
> >
> > Little ad on info:
> > Running this script on a vista ent. (with sql server installed to have the
> > requested regkeys) the script act as expected (error after renaming regkey
> > with regedit) ???
>
> When I ran your script on my WinXP machine then it behaved as expected.
> Renaming the value "CurrentVersion" to "OldVersion" caused the script to
> return a blank. Perhaps you were renaming the wrong value. Note also that
> your line [StdOut.WriteLine "Value: " & strValue] contains a misnomer.
> You're not returning a registry "value" but the "value data" for the value
> name "CurrentVersion".
>
>
>
My System SpecsSystem Spec
Old 03-12-2009   #4 (permalink)
Pegasus [MVP]


 
 

Re: registry caching/protecting

Sorry, I don't have a 64-bit system available to test your script. Instead
of WMI you might try the RegRead method of the WshShell object.


"Dan" <Dan@xxxxxx> wrote in message
news:117B6809-C10D-457C-B635-A21AF611D75A@xxxxxx
Quote:

> Pegasus,
> The problem is only on win2k3 x64 systems
>
> The script returns the data from
> HKLM\SOFTWARE\Wow6432Node\Microsoft\MSSQLServer\MSSQLServer\CurrentVersion
>
> and not from
> HKLM\SOFTWARE\Microsoft\MSSQLServer\MSSQLServer\CurrentVersion
>
> so renameing in the second hive does not change the script output...
> Thx for your quick response anyway.
>
>
>
> I'm sure not renaming wrong key as it only exists (
> "Pegasus [MVP]" wrote:
>
Quote:

>>
>> "Dan" <Dan@xxxxxx> wrote in message
>> news:7870CA45-42F7-402C-81C5-C1991D5259F3@xxxxxx
Quote:

>> > Hi all,
>> > I have a little script to read a registry value using WMI:
>> >
>> >
>> > Const HKEY_LOCAL_MACHINE = &H80000002
>> >
>> > Set StdOut = WScript.StdOut
>> > Set objReg =
>> > GetObject("winmgmts:{impersonationLevel=impersonate,authenticationLevel=Pkt}!\\.\root\default:StdRegProv")
>> >
>> > strKeyPath =
>> > "SOFTWARE\Microsoft\MSSQLServer\MSSQLServer\CurrentVersion"
>> > strValueName = "CurrentVersion"
>> > lStatus = objReg.GetStringValue
>> > (HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue)
>> >
>> > StdOut.WriteLine "Status: " & lStatus
>> > StdOut.WriteLine "Value: " & strValue
>> > Set objReg = Nothing
>> >
>> > Running on a Win 2003 R2 x64 SP2 the output looks like:
>> > Status: 0
>> > Value: 10.0.1600.22
>> >
>> > So far so good.
>> >
>> > If i now open regedit and rename the registry value let's say to
>> > "OldVersion" without changing the script, rerunning the script still
>> > shows
>> > to
>> > above result ????
>> > Is there any registry caching or registry protecting going on and how
>> > to
>> > prevent this from happen ??
>> >
>> > TIA
>> > acki
>> >
>> > Little ad on info:
>> > Running this script on a vista ent. (with sql server installed to have
>> > the
>> > requested regkeys) the script act as expected (error after renaming
>> > regkey
>> > with regedit) ???
>>
>> When I ran your script on my WinXP machine then it behaved as expected.
>> Renaming the value "CurrentVersion" to "OldVersion" caused the script to
>> return a blank. Perhaps you were renaming the wrong value. Note also that
>> your line [StdOut.WriteLine "Value: " & strValue] contains a misnomer.
>> You're not returning a registry "value" but the "value data" for the
>> value
>> name "CurrentVersion".
>>
>>
>>

My System SpecsSystem Spec
Old 03-12-2009   #5 (permalink)
Dan


 
 

Re: registry caching/protecting

If you run a .vbs script from your command prompt the cscript.exe in
C:\Windows\SysWOW64 is used.
Unfortunatly this is a 32-vit exe and therefor the keys/values in Wow6432
hive are shown... :-(
Just use cscript.exe in c:\windows\system (=64 bit version) and your happy
again :-)

acki

"Pegasus [MVP]" wrote:
Quote:

> Sorry, I don't have a 64-bit system available to test your script. Instead
> of WMI you might try the RegRead method of the WshShell object.
>
>
> "Dan" <Dan@xxxxxx> wrote in message
> news:117B6809-C10D-457C-B635-A21AF611D75A@xxxxxx
Quote:

> > Pegasus,
> > The problem is only on win2k3 x64 systems
> >
> > The script returns the data from
> > HKLM\SOFTWARE\Wow6432Node\Microsoft\MSSQLServer\MSSQLServer\CurrentVersion
> >
> > and not from
> > HKLM\SOFTWARE\Microsoft\MSSQLServer\MSSQLServer\CurrentVersion
> >
> > so renameing in the second hive does not change the script output...
> > Thx for your quick response anyway.
> >
> >
> >
> > I'm sure not renaming wrong key as it only exists (
> > "Pegasus [MVP]" wrote:
> >
Quote:

> >>
> >> "Dan" <Dan@xxxxxx> wrote in message
> >> news:7870CA45-42F7-402C-81C5-C1991D5259F3@xxxxxx
> >> > Hi all,
> >> > I have a little script to read a registry value using WMI:
> >> >
> >> >
> >> > Const HKEY_LOCAL_MACHINE = &H80000002
> >> >
> >> > Set StdOut = WScript.StdOut
> >> > Set objReg =
> >> > GetObject("winmgmts:{impersonationLevel=impersonate,authenticationLevel=Pkt}!\\.\root\default:StdRegProv")
> >> >
> >> > strKeyPath =
> >> > "SOFTWARE\Microsoft\MSSQLServer\MSSQLServer\CurrentVersion"
> >> > strValueName = "CurrentVersion"
> >> > lStatus = objReg.GetStringValue
> >> > (HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue)
> >> >
> >> > StdOut.WriteLine "Status: " & lStatus
> >> > StdOut.WriteLine "Value: " & strValue
> >> > Set objReg = Nothing
> >> >
> >> > Running on a Win 2003 R2 x64 SP2 the output looks like:
> >> > Status: 0
> >> > Value: 10.0.1600.22
> >> >
> >> > So far so good.
> >> >
> >> > If i now open regedit and rename the registry value let's say to
> >> > "OldVersion" without changing the script, rerunning the script still
> >> > shows
> >> > to
> >> > above result ????
> >> > Is there any registry caching or registry protecting going on and how
> >> > to
> >> > prevent this from happen ??
> >> >
> >> > TIA
> >> > acki
> >> >
> >> > Little ad on info:
> >> > Running this script on a vista ent. (with sql server installed to have
> >> > the
> >> > requested regkeys) the script act as expected (error after renaming
> >> > regkey
> >> > with regedit) ???
> >>
> >> When I ran your script on my WinXP machine then it behaved as expected.
> >> Renaming the value "CurrentVersion" to "OldVersion" caused the script to
> >> return a blank. Perhaps you were renaming the wrong value. Note also that
> >> your line [StdOut.WriteLine "Value: " & strValue] contains a misnomer.
> >> You're not returning a registry "value" but the "value data" for the
> >> value
> >> name "CurrentVersion".
> >>
> >>
> >>
>
>
>
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Caching PNG thumbnails in Vista Vista General
Caching PNG thumbnails in Vista Vista music pictures video
Disabling Thumbnail caching Vista file management
Floppy caching? Vista hardware & devices
memory caching Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46