RemS
Thu May 10 04:26:02 CDT 2007
"LM" wrote:
> On 10 touko, 01:35, "Michael Harris \(MVP\)" <mikhar.at.mvps.dot.org>
> wrote:
> > LM wrote:
> > > Hi all
> >
> > > I am trying to check what hardware profile this local machine is
> > > using. I want keep some drivers not running when they are not needed.
> >
> > > This much I got. There is 4 profiles in my pc, and current profile was
> > > number 3. But there is no "hit", the last print command does not work.
> >
> > > There is also a code in
> > > "
http://cwashington.netreach.net/depo/view.asp?
> > > Index=570&ScriptType=vbscript" but it gives an error. This code is
> > > from MS.
> >
> > > The code:
> >
> > > Const HKEY_CURRENT_USER = &H80000001
> > > Const HKEY_LOCAL_MACHINE = &H80000002
> >
> > > strComputer = "."
> >
> > > Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
> > > strComputer & "\root\default:StdRegProv")
> >
> > > strKeyPath = "SYSTEM\CurrentControlSet\Control\IDConfigDB\"
> > > strValueName = "CurrentConfig"
> > > oReg.GetDWORDValue HKEY_CURRENT_USER,strKeyPath,strValueName,dwValue
> > > Wscript.Echo "CurrentConfig: " & dwValue
> >
> > > strKeyPath = "SYSTEM\CurrentControlSet\Control\IDConfigDB\"
> > > strValueName = "CurrentConfig"
> > > oReg.GetStringValue
> > > HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
> > > Wscript.Echo "Current WSH Trust Policy Value: " & strValue
> > > 'dwValue=3
> > > if dwValue=0 then Wscript.Echo "A hit"
> >
> > I suggest testing the return code. For example, the part of your example
> > doesn't exactly give me a dwValue, but at least I get a return code of 2...
> >
> > Const HKEY_CURRENT_USER = &H80000001
> > Const HKEY_LOCAL_MACHINE = &H80000002
> >
> > strComputer = "."
> >
> > Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
> > strComputer & "\root\default:StdRegProv")
> >
> > strKeyPath = "SYSTEM\CurrentControlSet\Control\IDConfigDB\"
> > strValueName = "CurrentConfig"
> > rc= oReg.GetDWORDValue(HKEY_CURRENT_USER,strKeyPath,strValueName,dwValue)
> >
> > Wscript.Echo "rc=" & rc
> > Wscript.Echo "CurrentConfig: " & dwValue
> >
> > 'RC = 0 for success
> > 'RC = 1 for key read with no default value
> > 'RC = 2 for key not found
> > 'RC = 6 for invalid hive
> >
> > --
> > Michael Harris
> > Microsoft.MVP.Scripting
>
>
> Same result here too. What might be the problem. There is a "path"
> "SYSTEM\CurrentControlSet\Control\IDConfigDB\CurrentConfig" and there
> seems to be REG_DWORD variable "CurrentConfig". And the rest of the
> code is from MSDN. I could go on guessing. But some help would be
> nice.
>
> LM
>
re-type the strKeyPath =
* open regedit, go to the key, rightclick -> Copy Key Name
* paste the name of the Key in your script,
then:
< remove "HKEY_CURRENT_USER\" from that line.
< And the key should not end with \
Now you absolute sure there isn't a typo or syntax error in the value
\RemS