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"

Re: trying to read a registry value DWORD by LM

LM
Wed May 09 13:53:37 CDT 2007

On 9 touko, 21:34, LM <sala.n...@mail.com> 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"


Perhaps I should tell that I test these scripts by typing its name on
the command prompt. I have zero knowledge about other ways. I have
about 1% more knowledge testing scripts this way.


Re: trying to read a registry value DWORD by Michael

Michael
Wed May 09 17:35:45 CDT 2007

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



Re: trying to read a registry value DWORD by LM

LM
Thu May 10 03:19:53 CDT 2007

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: trying to read a registry value DWORD by RemS

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

Re: trying to read a registry value DWORD by LM

LM
Thu May 10 09:17:16 CDT 2007

On 10 touko, 12:26, \RemS <R...@discussions.microsoft.com> wrote:

> 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
It works now. It looks like there was a error in the path.

Code:
Const HKEY_CURRENT_USER = &H80000001
Const HKEY_LOCAL_MACHINE = &H80000002
'HKEY_LOCAL_MACHINE
'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\IDConfigDB
'CurrentConfig
strComputer = "."
dwValue=99
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
strComputer & "\root\default:StdRegProv")

strKeyPath = "SYSTEM\CurrentControlSet\Control\IDConfigDB"
strValueName = "CurrentConfig"
'strValueName = ""
rc=
oReg.GetDWORDValue(HKEY_LOCAL_MACHINE,strKeyPath,strValueName,dwValue)

'Wscript.Echo "rc=" & rc
if rc=0 then
Wscript.Echo "CurrentConfig: " & dwValue
else
Wscript.Echo "Error"
end if

Thanks
LM