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 - Set Local Computer Description

Reply
 
Old 05-02-2009   #1 (permalink)
Jeremy


 
 

Set Local Computer Description

I have been doing this for years in XP and Server 2003, but recently I have
been installing Vista x64 Edition for some specific needs. This code is
part of a workstation startup script that pulls the description from AD and
makes it the local description on the computer. This does not work in Vista
x64 or Server 2008 x64 and I have found no explanation on the Internet as of
yet. I have not tested in x86 installs of the same OS. Yes, I am running
it as administrator while testing, if I do not, I receive Access Denied.


sComputer = "."
Set Obj = GetObject("winmgmts:\\" & sComputer &
"\root\cimv2").InstancesOf("Win32_OperatingSystem")
For Each x In Obj
x.Description = "This is the computer description."
x.Put_
Next


The object is being created just fine. I can use other methods on the
object successfully like GetText_ . I have found no documentation that says
Put_ shouldn't work.
Any help would be appreciated. This one is driving me crazy.

When running, I receive the following error:
---------------------------
Windows Script Host
---------------------------
Script: C:\Users\username\Desktop\test.vbs
Line: 6
Char: 4
Error: Value out of range
Code: 8004102B
Source: SWbemObjectEx

---------------------------
OK
---------------------------

Thanks




My System SpecsSystem Spec
Old 05-03-2009   #2 (permalink)
Andrew McLaren


 
 

Re: Set Local Computer Description

Hi Jeremy,

I dunno the exact answer, but this issue does ring a bell ...

Note that the WSH error message reports WBEM_E_VALUE_OUT_OF_RANGE for *Line
6* of your script. So the problem is not with the Put_ method; it's on the
*Next* statement.

Win32_OperatingSystem returns a collection, which has always been a bit
weird because you can only have one OS instance at a time on a given
machine. I seem to recall - from some previous case in the last 3 years -
that on Vista, you now need to explicitly handle WMI collections which have
a cardinality of one, by using an "ItemIndex" property (eg
obj.<prop>.ItemIndex(0), to identify the first, and only, member of the
collection). Prior to Vista, WMI was less strict about this; so your
existing syntax should work okay on XP or 2003.

If you Google for "Vista and WMI and ItemIndex and Win32_OperatingSystem"
you might find some more precise info.

Hope this helps a bit,

Andrew
--
amclar at optusnet dot com dot au



My System SpecsSystem Spec
Old 05-03-2009   #3 (permalink)
Jon


 
 

Re: Set Local Computer Description


"Jeremy" <trombone79atgmail.com> wrote in message
news:ulb1gnzyJHA.436@xxxxxx
Quote:

>I have been doing this for years in XP and Server 2003, but recently I have
> been installing Vista x64 Edition for some specific needs. This code is
> part of a workstation startup script that pulls the description from AD
> and
> makes it the local description on the computer. This does not work in
> Vista
> x64 or Server 2008 x64 and I have found no explanation on the Internet as
> of
> yet. I have not tested in x86 installs of the same OS. Yes, I am running
> it as administrator while testing, if I do not, I receive Access Denied.
>
>
> sComputer = "."
> Set Obj = GetObject("winmgmts:\\" & sComputer &
> "\root\cimv2").InstancesOf("Win32_OperatingSystem")
> For Each x In Obj
> x.Description = "This is the computer description."
> x.Put_
> Next
>
>
> The object is being created just fine. I can use other methods on the
> object successfully like GetText_ . I have found no documentation that
> says
> Put_ shouldn't work.
> Any help would be appreciated. This one is driving me crazy.
>
> When running, I receive the following error:
> ---------------------------
> Windows Script Host
> ---------------------------
> Script: C:\Users\username\Desktop\test.vbs
> Line: 6
> Char: 4
> Error: Value out of range
> Code: 8004102B
> Source: SWbemObjectEx
>
> ---------------------------
> OK
> ---------------------------
>
> Thanks
>
>
>



You could set it using the following command (run elevated).....

net config server /SRVCOMMENT:"My description"

which could be integrated into a VBScript.



Possibly a bug with WMI. The same error occurs with Powershell.....

PS (1) > gwmi Win32_OperatingSystem | foreach
{$_.Description="whatever";$_.Put()}
Exception calling "Put" with "0" argument(s): "Exception calling "Put" with
"0" argument(
s): "Value out of range ""
At line:1 char:71
+ gwmi Win32_OperatingSystem | foreach {$_.Description="whatever";$_.Put(
<<<< )}

and also using the 'wmic' command .....

PS (2) > wmic os set description="TryAgain"
Updating property(s) of '\\JONV\ROOT\CIMV2:Win32_OperatingSystem=@'
ERROR:
Code = 0x8004102b
Description = Value out of range
Facility = WMI


so the error isn't VBScript specific.


--
Jon



My System SpecsSystem Spec
Old 05-03-2009   #4 (permalink)
Jeremy


 
 

Re: Set Local Computer Description

The line the error is on may be slightly different than the line of the code
I pasted in the post. The error is on the Put_ line.


"Andrew McLaren" <andrew.mclaren@xxxxxx> wrote in message
news:OyzaP2%23yJHA.3476@xxxxxx
Quote:

> Hi Jeremy,
>
> I dunno the exact answer, but this issue does ring a bell ...
>
> Note that the WSH error message reports WBEM_E_VALUE_OUT_OF_RANGE for
> *Line 6* of your script. So the problem is not with the Put_ method; it's
> on the *Next* statement.
>
> Win32_OperatingSystem returns a collection, which has always been a bit
> weird because you can only have one OS instance at a time on a given
> machine. I seem to recall - from some previous case in the last 3 years -
> that on Vista, you now need to explicitly handle WMI collections which
> have a cardinality of one, by using an "ItemIndex" property (eg
> obj.<prop>.ItemIndex(0), to identify the first, and only, member of the
> collection). Prior to Vista, WMI was less strict about this; so your
> existing syntax should work okay on XP or 2003.
>
> If you Google for "Vista and WMI and ItemIndex and Win32_OperatingSystem"
> you might find some more precise info.
>
> Hope this helps a bit,
>
> Andrew
> --
> amclar at optusnet dot com dot au
>
>
>

My System SpecsSystem Spec
Old 05-03-2009   #5 (permalink)
Andrew McLaren


 
 

Re: Set Local Computer Description

"Jeremy" <trombone79atgmail.com> wrote ...
Quote:

> The line the error is on may be slightly different than the line of the
> code I pasted in the post. The error is on the Put_ line.
No; believe me, the error comes from the "Next" line! :-) The word-wrap,
etc, doesn't matter; what does matter is the *line* in the script, as
recognised by the VBScript tokenizer. The error message could have said:

First-order syntactic object in script: 6
Second-order syntactic object in script: 4

.... but that would be pretty obscure and verbose. The 6th "line" in your
script is indeed "Next". And the error constant WBEM_E_VALUE_OUT_OF_RANGE is
much more obviously applicable to a Next, than to a Put_.

As I said: if you Google for "Vista and WMI and ItemIndex and
Win32_OperatingSystem" you might find some more precise info. Here you go:

http://www.microsoft.com/technet/scr...a/indexer.mspx
http://www.microsoft.com/technet/scr...ista/wmi1.mspx
http://msdn.microsoft.com/en-us/libr...00(VS.85).aspx

These 3 links will lead you to the answer; which was as I suspected, to use
ItemIndex. The exact syntax you'll need to use to modify your script is, um
.... left as an exercise for the reader :-) I don't have time now to test it
myself, and the experience will help you understand the nature of the error
message.

Good luck, you're very close to the solution now.

Andrew
--
amclar at optusnet dot com dot au


My System SpecsSystem Spec
Old 05-04-2009   #6 (permalink)
Alex K. Angelopoulos


 
 

Re: Set Local Computer Description

We're having a long party in the other thread about this topic. Thanks for
the non-VBScript confirmation. : )

I think Jeremy was trying to avoid "net config" due to the lack of remote
usability. There's also an issue with "net config" disabling the LAN Manager
Service's autotuning. : (

"Jon" <Email_Address@xxxxxx> wrote in message
news:#pkyt6$yJHA.3404@xxxxxx
Quote:

> You could set it using the following command (run elevated).....
>
> net config server /SRVCOMMENT:"My description"
>
> which could be integrated into a VBScript.

Quote:

> Possibly a bug with WMI. The same error occurs with Powershell.....
>
> PS (1) > gwmi Win32_OperatingSystem | foreach
> {$_.Description="whatever";$_.Put()}
> Exception calling "Put" with "0" argument(s): "Exception calling "Put"
> with "0" argument(
> s): "Value out of range ""
> At line:1 char:71
> + gwmi Win32_OperatingSystem | foreach
> {$_.Description="whatever";$_.Put( <<<< )}
>
> and also using the 'wmic' command .....
>
> PS (2) > wmic os set description="TryAgain"
> Updating property(s) of '\\JONV\ROOT\CIMV2:Win32_OperatingSystem=@'
> ERROR:
> Code = 0x8004102b
> Description = Value out of range
> Facility = WMI
>
>
> so the error isn't VBScript specific.
>
>
> --
> Jon
>
>
>
My System SpecsSystem Spec
Old 05-04-2009   #7 (permalink)
Jon


 
 

Re: Set Local Computer Description


"Alex K. Angelopoulos" <aka(at)mvps.org> wrote in message
news:eMvylmOzJHA.3404@xxxxxx
Quote:

> We're having a long party in the other thread about this topic. Thanks for
> the non-VBScript confirmation. : )
>
> I think Jeremy was trying to avoid "net config" due to the lack of remote
> usability. There's also an issue with "net config" disabling the LAN
> Manager Service's autotuning. : (
>


You're welcome. I'm glad someone read it. I was beginning to think it had
been overlooked. ;-)

That's interesting about autotuning. Wasn't aware of the side effects of the
'net config' command.Your registry solution with 'srvcomment' at

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters

looked like it could potentially work if it were also combined with a
suitable 'refresh' ie a reboot or perhaps a stop / start of the 'Server' /
'Browser' services (??) I was thinking along similar lines using
'WshShell.RegWrite', but was too lazy to test out the 'reboot theory'.

Anyhow hope the party has a happy ending :-)

--
Jon




My System SpecsSystem Spec
Old 05-04-2009   #8 (permalink)
Alex K. Angelopoulos


 
 

Re: Set Local Computer Description

The ItemIndex thing on Vista is _very_ cool, Andrew. I didn't even know it
existed until your post. That wasn't the problem, but I'm glad you posted
anyway. : )

Jeremy's code works fine on post-Vista systems I tested (2008, Win7 x64
beta), but fails on not only his x64 Vista but also two other 32-bit Vistas
and _his_ x64 Windows 2008 system. I tested the technique using ItemIndex on
my failing Vista box just in case, and it fails there as well with the
usual "out of range" error.

Demo code below. I'm going to try a WMI repository rebuild on my affected
system to see if that may be the issue; the error really _does_ come from
the Put_ line, and you got me thinking that the issue might be WMI truly
trying to report what it thinks is a problem. If there was a common glitch
during repository build, I could see it mucking up and using the wrong
limits when it qualifies a value passed back.

Set Obj =
GetObject("winmgmts:\\.\root\cimv2").InstancesOf("Win32_OperatingSystem")
set os = Obj.ItemIndex(0)
WScript.Echo os.Description
os.Description = "A New Description"
os.Put_ ' <-- boom! outta range.

"Andrew McLaren" <andrew.mclaren@xxxxxx> wrote in message
news:#Dg6eiEzJHA.5684@xxxxxx
Quote:

> "Jeremy" <trombone79atgmail.com> wrote ...
Quote:

>> The line the error is on may be slightly different than the line of the
>> code I pasted in the post. The error is on the Put_ line.
>
> No; believe me, the error comes from the "Next" line! :-) The word-wrap,
> etc, doesn't matter; what does matter is the *line* in the script, as
> recognised by the VBScript tokenizer. The error message could have said:
>
> First-order syntactic object in script: 6
> Second-order syntactic object in script: 4
>
> ... but that would be pretty obscure and verbose. The 6th "line" in your
> script is indeed "Next". And the error constant WBEM_E_VALUE_OUT_OF_RANGE
> is much more obviously applicable to a Next, than to a Put_.
>
> As I said: if you Google for "Vista and WMI and ItemIndex and
> Win32_OperatingSystem" you might find some more precise info. Here you go:
>
> http://www.microsoft.com/technet/scr...a/indexer.mspx
> http://www.microsoft.com/technet/scr...ista/wmi1.mspx
> http://msdn.microsoft.com/en-us/libr...00(VS.85).aspx
>
> These 3 links will lead you to the answer; which was as I suspected, to
> use ItemIndex. The exact syntax you'll need to use to modify your script
> is, um ... left as an exercise for the reader :-) I don't have time now to
> test it myself, and the experience will help you understand the nature of
> the error message.
>
> Good luck, you're very close to the solution now.
>
> Andrew
> --
> amclar at optusnet dot com dot au
>
>
My System SpecsSystem Spec
Old 05-05-2009   #9 (permalink)
Richard Mueller [MVP]


 
 

Re: Set Local Computer Description

I also tried ItemIndex on my 32-bit Vista machine with the same result
(value out of range error). I used slightly different code:

strComputer = "West01"
Set colOSs = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate,authenticationLevel=Pkt}!\\" _
& strComputer & "\root\cimv2").InstancesOf("Win32_OperatingSystem")
colOSs.ItemIndex(0).Description = "Test Lab"
colOSs.ItemIndex(0).Put_

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--

"Alex K. Angelopoulos" <aka(at)mvps.org> wrote in message
news:eGyRjFQzJHA.2324@xxxxxx
Quote:

> The ItemIndex thing on Vista is _very_ cool, Andrew. I didn't even know it
> existed until your post. That wasn't the problem, but I'm glad you posted
> anyway. : )
>
> Jeremy's code works fine on post-Vista systems I tested (2008, Win7 x64
> beta), but fails on not only his x64 Vista but also two other 32-bit
> Vistas and _his_ x64 Windows 2008 system. I tested the technique using
> ItemIndex on my failing Vista box just in case, and it fails there as
> well with the usual "out of range" error.
>
> Demo code below. I'm going to try a WMI repository rebuild on my affected
> system to see if that may be the issue; the error really _does_ come from
> the Put_ line, and you got me thinking that the issue might be WMI truly
> trying to report what it thinks is a problem. If there was a common glitch
> during repository build, I could see it mucking up and using the wrong
> limits when it qualifies a value passed back.
>
> Set Obj =
> GetObject("winmgmts:\\.\root\cimv2").InstancesOf("Win32_OperatingSystem")
> set os = Obj.ItemIndex(0)
> WScript.Echo os.Description
> os.Description = "A New Description"
> os.Put_ ' <-- boom! outta range.
>
> "Andrew McLaren" <andrew.mclaren@xxxxxx> wrote in message
> news:#Dg6eiEzJHA.5684@xxxxxx
Quote:

>> "Jeremy" <trombone79atgmail.com> wrote ...
Quote:

>>> The line the error is on may be slightly different than the line of the
>>> code I pasted in the post. The error is on the Put_ line.
>>
>> No; believe me, the error comes from the "Next" line! :-) The word-wrap,
>> etc, doesn't matter; what does matter is the *line* in the script, as
>> recognised by the VBScript tokenizer. The error message could have said:
>>
>> First-order syntactic object in script: 6
>> Second-order syntactic object in script: 4
>>
>> ... but that would be pretty obscure and verbose. The 6th "line" in your
>> script is indeed "Next". And the error constant WBEM_E_VALUE_OUT_OF_RANGE
>> is much more obviously applicable to a Next, than to a Put_.
>>
>> As I said: if you Google for "Vista and WMI and ItemIndex and
>> Win32_OperatingSystem" you might find some more precise info. Here you
>> go:
>>
>>
>> http://www.microsoft.com/technet/scr...a/indexer.mspx
>> http://www.microsoft.com/technet/scr...ista/wmi1.mspx
>> http://msdn.microsoft.com/en-us/libr...00(VS.85).aspx
>>
>> These 3 links will lead you to the answer; which was as I suspected, to
>> use ItemIndex. The exact syntax you'll need to use to modify your script
>> is, um ... left as an exercise for the reader :-) I don't have time now
>> to test it myself, and the experience will help you understand the nature
>> of the error message.
>>
>> Good luck, you're very close to the solution now.
>>
>> Andrew
>> --
>> amclar at optusnet dot com dot au
>>
>>

My System SpecsSystem Spec
Old 05-05-2009   #10 (permalink)
Jeremy


 
 

Re: Set Local Computer Description

Thanks all for helping out. I'm leaning towards a problem with WMI in
Vista, but a call to MS will determine that one way or the other.


"Richard Mueller [MVP]" <rlmueller-nospam@xxxxxx> wrote in
message news:e3c35kTzJHA.3404@xxxxxx
Quote:

>I also tried ItemIndex on my 32-bit Vista machine with the same result
>(value out of range error). I used slightly different code:
>
> strComputer = "West01"
> Set colOSs = GetObject("winmgmts:" _
> & "{impersonationLevel=impersonate,authenticationLevel=Pkt}!\\" _
> & strComputer & "\root\cimv2").InstancesOf("Win32_OperatingSystem")
> colOSs.ItemIndex(0).Description = "Test Lab"
> colOSs.ItemIndex(0).Put_
>
> --
> Richard Mueller
> MVP Directory Services
> Hilltop Lab - http://www.rlmueller.net
> --
>
> "Alex K. Angelopoulos" <aka(at)mvps.org> wrote in message
> news:eGyRjFQzJHA.2324@xxxxxx
Quote:

>> The ItemIndex thing on Vista is _very_ cool, Andrew. I didn't even know
>> it existed until your post. That wasn't the problem, but I'm glad you
>> posted anyway. : )
>>
>> Jeremy's code works fine on post-Vista systems I tested (2008, Win7 x64
>> beta), but fails on not only his x64 Vista but also two other 32-bit
>> Vistas and _his_ x64 Windows 2008 system. I tested the technique using
>> ItemIndex on my failing Vista box just in case, and it fails there as
>> well with the usual "out of range" error.
>>
>> Demo code below. I'm going to try a WMI repository rebuild on my affected
>> system to see if that may be the issue; the error really _does_ come from
>> the Put_ line, and you got me thinking that the issue might be WMI truly
>> trying to report what it thinks is a problem. If there was a common
>> glitch during repository build, I could see it mucking up and using the
>> wrong limits when it qualifies a value passed back.
>>
>> Set Obj =
>> GetObject("winmgmts:\\.\root\cimv2").InstancesOf("Win32_OperatingSystem")
>> set os = Obj.ItemIndex(0)
>> WScript.Echo os.Description
>> os.Description = "A New Description"
>> os.Put_ ' <-- boom! outta range.
>>
>> "Andrew McLaren" <andrew.mclaren@xxxxxx> wrote in message
>> news:#Dg6eiEzJHA.5684@xxxxxx
Quote:

>>> "Jeremy" <trombone79atgmail.com> wrote ...
>>>> The line the error is on may be slightly different than the line of the
>>>> code I pasted in the post. The error is on the Put_ line.
>>>
>>> No; believe me, the error comes from the "Next" line! :-) The
>>> word-wrap, etc, doesn't matter; what does matter is the *line* in the
>>> script, as recognised by the VBScript tokenizer. The error message could
>>> have said:
>>>
>>> First-order syntactic object in script: 6
>>> Second-order syntactic object in script: 4
>>>
>>> ... but that would be pretty obscure and verbose. The 6th "line" in your
>>> script is indeed "Next". And the error constant
>>> WBEM_E_VALUE_OUT_OF_RANGE is much more obviously applicable to a Next,
>>> than to a Put_.
>>>
>>> As I said: if you Google for "Vista and WMI and ItemIndex and
>>> Win32_OperatingSystem" you might find some more precise info. Here you
>>> go:
>>>
>>>
>>> http://www.microsoft.com/technet/scr...a/indexer.mspx
>>> http://www.microsoft.com/technet/scr...ista/wmi1.mspx
>>> http://msdn.microsoft.com/en-us/libr...00(VS.85).aspx
>>>
>>> These 3 links will lead you to the answer; which was as I suspected, to
>>> use ItemIndex. The exact syntax you'll need to use to modify your script
>>> is, um ... left as an exercise for the reader :-) I don't have time now
>>> to test it myself, and the experience will help you understand the
>>> nature of the error message.
>>>
>>> Good luck, you're very close to the solution now.
>>>
>>> Andrew
>>> --
>>> amclar at optusnet dot com dot au
>>>
>>>
>
>

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Use VBScript to Set Local Computer Description Vista General
Use VBScript to Set Local Computer Description VB Script
Re: Set Local Computer Description Vista General
Computer description in Network places Vista networking & sharing
Windows Vista and Computer description Vista networking & sharing


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