|
Prev: Create a output stream with quote enclosed fields
Next: Need sample for reading value from and writing value to cell E53 f
From: PaulM on 17 Jun 2008 01:54 Need help: If this script works: Const HKLM = &H80000002 strComputer = "." Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}" _ & "!\\" & strComputer & "\root\default:StdRegProv") sPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" oReg.EnumKey HKLM, sPath, aKeys For Each sKey in aKeys oReg.GetStringValue HKLM, sPath & "\" & sKey, "UninstallString", sName If Not IsNull(sName) Then sText = sText & sName & vbCr Next WScript.Echo sText This script works: Const HKLM = &H80000002 strComputer = "." Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}" _ & "!\\" & strComputer & "\root\default:StdRegProv") sPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" oReg.EnumKey HKLM, sPath, aKeys For Each sKey in aKeys oReg.GetStringValue HKLM, sPath & "\" & sKey, "DisplayName", sName If Not IsNull(sName) Then sList = sList & sName & vbCr Next WScript.Echo sList Why doesn't this script work: Const HKLM = &H80000002 strComputer = "." Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}" _ & "!\\" & strComputer & "\root\default:StdRegProv") sPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Run" oReg.EnumKey HKLM, sPath, aKeys For Each sKey in aKeys oReg.GetStringValue HKLM, sPath & "\" & sKey, "DisplayName", sName If Not IsNull(sName) Then sList = sList & sName & vbCr Next WScript.Echo sList
From: Joe Fawcett on 17 Jun 2008 03:04 "PaulM" <paul(a)paulsxp.com> wrote in message news:%23r0xN6D0IHA.2064(a)TK2MSFTNGP05.phx.gbl... > Need help: > > If this script works: > > Const HKLM = &H80000002 > > strComputer = "." > > Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}" _ > & "!\\" & strComputer & "\root\default:StdRegProv") > > sPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" > oReg.EnumKey HKLM, sPath, aKeys > > For Each sKey in aKeys > oReg.GetStringValue HKLM, sPath & "\" & sKey, "UninstallString", sName > If Not IsNull(sName) Then sText = sText & sName & vbCr Next > WScript.Echo sText > > This script works: > > Const HKLM = &H80000002 > > strComputer = "." > > Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}" _ > & "!\\" & strComputer & "\root\default:StdRegProv") > > sPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" > oReg.EnumKey HKLM, sPath, aKeys > > For Each sKey in aKeys > oReg.GetStringValue HKLM, sPath & "\" & sKey, "DisplayName", sName > If Not IsNull(sName) Then sList = sList & sName & vbCr Next > WScript.Echo sList > > Why doesn't this script work: > > Const HKLM = &H80000002 > > strComputer = "." > > Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}" _ > & "!\\" & strComputer & "\root\default:StdRegProv") > sPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Run" > oReg.EnumKey HKLM, sPath, aKeys > > For Each sKey in aKeys > oReg.GetStringValue HKLM, sPath & "\" & sKey, "DisplayName", sName > If Not IsNull(sName) Then sList = sList & sName & vbCr > Next > > WScript.Echo sList Define "does not work", does it error, not return what you'd expect etc? -- Joe Fawcett (MVP - XML) http://joe.fawcett.name
From: PaulM on 17 Jun 2008 09:41 It returns a blank box with OK. Nothing in it. "Joe Fawcett" <joefawcett(a)newsgroup.nospam> wrote in message news:eDrGUhE0IHA.3680(a)TK2MSFTNGP05.phx.gbl... > "PaulM" <paul(a)paulsxp.com> wrote in message > news:%23r0xN6D0IHA.2064(a)TK2MSFTNGP05.phx.gbl... >> Need help: >> >> If this script works: >> >> Const HKLM = &H80000002 >> >> strComputer = "." >> >> Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}" _ >> & "!\\" & strComputer & "\root\default:StdRegProv") >> >> sPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" >> oReg.EnumKey HKLM, sPath, aKeys >> >> For Each sKey in aKeys >> oReg.GetStringValue HKLM, sPath & "\" & sKey, "UninstallString", sName >> If Not IsNull(sName) Then sText = sText & sName & vbCr Next >> WScript.Echo sText >> >> This script works: >> >> Const HKLM = &H80000002 >> >> strComputer = "." >> >> Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}" _ >> & "!\\" & strComputer & "\root\default:StdRegProv") >> >> sPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" >> oReg.EnumKey HKLM, sPath, aKeys >> >> For Each sKey in aKeys >> oReg.GetStringValue HKLM, sPath & "\" & sKey, "DisplayName", sName >> If Not IsNull(sName) Then sList = sList & sName & vbCr Next >> WScript.Echo sList >> >> Why doesn't this script work: >> >> Const HKLM = &H80000002 >> >> strComputer = "." >> >> Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}" _ >> & "!\\" & strComputer & "\root\default:StdRegProv") >> sPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Run" >> oReg.EnumKey HKLM, sPath, aKeys >> >> For Each sKey in aKeys >> oReg.GetStringValue HKLM, sPath & "\" & sKey, "DisplayName", sName >> If Not IsNull(sName) Then sList = sList & sName & vbCr >> Next >> >> WScript.Echo sList > Define "does not work", does it error, not return what you'd expect etc? > > -- > > Joe Fawcett (MVP - XML) > > http://joe.fawcett.name > >
From: Tom Lavedas on 17 Jun 2008 09:46 On Jun 17, 1:54 am, "PaulM" <p...(a)paulsxp.com> wrote: > Need help: > > If this script works: > > Const HKLM = &H80000002 > > strComputer = "." > > Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}" _ > & "!\\" & strComputer & "\root\default:StdRegProv") > > sPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" > oReg.EnumKey HKLM, sPath, aKeys > > For Each sKey in aKeys > oReg.GetStringValue HKLM, sPath & "\" & sKey, "UninstallString", sName > If Not IsNull(sName) Then sText = sText & sName & vbCr > Next > WScript.Echo sText > > This script works: > > Const HKLM = &H80000002 > > strComputer = "." > > Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}" _ > & "!\\" & strComputer & "\root\default:StdRegProv") > > sPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" > oReg.EnumKey HKLM, sPath, aKeys > > For Each sKey in aKeys > oReg.GetStringValue HKLM, sPath & "\" & sKey, "DisplayName", sName > If Not IsNull(sName) Then sList = sList & sName & vbCr > Next > WScript.Echo sList > > Why doesn't this script work: > > Const HKLM = &H80000002 > > strComputer = "." > > Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}" _ > & "!\\" & strComputer & "\root\default:StdRegProv") > sPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Run" > oReg.EnumKey HKLM, sPath, aKeys > > For Each sKey in aKeys > oReg.GetStringValue HKLM, sPath & "\" & sKey, "DisplayName", sName > If Not IsNull(sName) Then sList = sList & sName & vbCr > Next > > WScript.Echo sList In the first case, there are many subKEYS under the named key. In the second case, all (or most) of the entries are VALUES. Try something like this instead ... oReg.EnumValues HKLM, sPath, aValueNames, aValueTypes For Each sValueName in aValueNames oReg.GetStringValue HKLM, sPath, sValueName, sValue If Not IsNull(sValueName) Then _ sList = sList & sValueName & vbTab & sValue & vbCr Next Tom Lavedas =========== http://members.cox.net/tglbatch/wsh/
From: PaulM on 17 Jun 2008 09:56
I will give it a try and get back to you. "Tom Lavedas" <tglbatch(a)cox.net> wrote in message news:73cb9ecf-cbc7-49b6-9314-4baa0062c779(a)m45g2000hsb.googlegroups.com... > On Jun 17, 1:54 am, "PaulM" <p...(a)paulsxp.com> wrote: >> Need help: >> >> If this script works: >> >> Const HKLM = &H80000002 >> >> strComputer = "." >> >> Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}" _ >> & "!\\" & strComputer & "\root\default:StdRegProv") >> >> sPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" >> oReg.EnumKey HKLM, sPath, aKeys >> >> For Each sKey in aKeys >> oReg.GetStringValue HKLM, sPath & "\" & sKey, "UninstallString", sName >> If Not IsNull(sName) Then sText = sText & sName & vbCr >> Next >> WScript.Echo sText >> >> This script works: >> >> Const HKLM = &H80000002 >> >> strComputer = "." >> >> Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}" _ >> & "!\\" & strComputer & "\root\default:StdRegProv") >> >> sPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" >> oReg.EnumKey HKLM, sPath, aKeys >> >> For Each sKey in aKeys >> oReg.GetStringValue HKLM, sPath & "\" & sKey, "DisplayName", sName >> If Not IsNull(sName) Then sList = sList & sName & vbCr >> Next >> WScript.Echo sList >> >> Why doesn't this script work: >> >> Const HKLM = &H80000002 >> >> strComputer = "." >> >> Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}" _ >> & "!\\" & strComputer & "\root\default:StdRegProv") >> sPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Run" >> oReg.EnumKey HKLM, sPath, aKeys >> >> For Each sKey in aKeys >> oReg.GetStringValue HKLM, sPath & "\" & sKey, "DisplayName", sName >> If Not IsNull(sName) Then sList = sList & sName & vbCr >> Next >> >> WScript.Echo sList > > In the first case, there are many subKEYS under the named key. In the > second case, all (or most) of the entries are VALUES. Try something > like this instead ... > > oReg.EnumValues HKLM, sPath, aValueNames, aValueTypes > > For Each sValueName in aValueNames > oReg.GetStringValue HKLM, sPath, sValueName, sValue > If Not IsNull(sValueName) Then _ > sList = sList & sValueName & vbTab & sValue & vbCr > Next > > Tom Lavedas > =========== > http://members.cox.net/tglbatch/wsh/ |