|
| | |||||||
| Windows Vista Discuss the different versions of Windows Vista, Fuji, or Vienna |
| | LinkBack | Thread Tools |
| |||
| 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 |
| |||
| 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 |
| |||
| Re: Set Local Computer Description "Jeremy" <trombone79atgmail.com> wrote in message news:ulb1gnzyJHA.436@TK2MSFTNGP02.phx.gbl...[color=blue] >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 > > >[/color] 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 |
| |||
| 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@somewhere.com> wrote in message news:OyzaP2%23yJHA.3476@TK2MSFTNGP05.phx.gbl...[color=blue] > 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 > > >[/color] |
| |||
| Re: Set Local Computer Description "Jeremy" <trombone79atgmail.com> wrote ...[color=blue] > 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.[/color] 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: [url]http://www.microsoft.com/technet/scriptcenter/topics/vista/indexer.mspx[/url] [url]http://www.microsoft.com/technet/scriptcenter/topics/vista/wmi1.mspx[/url] [url]http://msdn.microsoft.com/en-us/library/aa826600(VS.85).aspx[/url] 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 |
| |||
| 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@SomewhereOrOther.com> wrote in message news:#pkyt6$yJHA.3404@TK2MSFTNGP02.phx.gbl... [color=blue] > You could set it using the following command (run elevated)..... > > net config server /SRVCOMMENT:"My description" > > which could be integrated into a VBScript.[/color] [color=blue] > 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 > > >[/color] |
| |||
| Re: Set Local Computer Description "Alex K. Angelopoulos" <aka(at)mvps.org> wrote in message news:eMvylmOzJHA.3404@TK2MSFTNGP02.phx.gbl...[color=blue] > 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. : ( >[/color] 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 |
| |||
| 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@somewhere.com> wrote in message news:#Dg6eiEzJHA.5684@TK2MSFTNGP04.phx.gbl...[color=blue] > "Jeremy" <trombone79atgmail.com> wrote ...[color=green] >> 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.[/color] > > 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: > > [url]http://www.microsoft.com/technet/scriptcenter/topics/vista/indexer.mspx[/url] > [url]http://www.microsoft.com/technet/scriptcenter/topics/vista/wmi1.mspx[/url] > [url]http://msdn.microsoft.com/en-us/library/aa826600(VS.85).aspx[/url] > > 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 > >[/color] |
| |||
| 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 - [url]http://www.rlmueller.net[/url] -- "Alex K. Angelopoulos" <aka(at)mvps.org> wrote in message news:eGyRjFQzJHA.2324@TK2MSFTNGP06.phx.gbl...[color=blue] > 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@somewhere.com> wrote in message > news:#Dg6eiEzJHA.5684@TK2MSFTNGP04.phx.gbl...[color=green] >> "Jeremy" <trombone79atgmail.com> wrote ...[color=darkred] >>> 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.[/color] >> >> 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: >> >> >> [url]http://www.microsoft.com/technet/scriptcenter/topics/vista/indexer.mspx[/url] >> [url]http://www.microsoft.com/technet/scriptcenter/topics/vista/wmi1.mspx[/url] >> [url]http://msdn.microsoft.com/en-us/library/aa826600(VS.85).aspx[/url] >> >> 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 >> >>[/color][/color] |
| |||
| 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@ameritech.nospam.net> wrote in message news:e3c35kTzJHA.3404@TK2MSFTNGP02.phx.gbl...[color=blue] >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 - [url]http://www.rlmueller.net[/url] > -- > > "Alex K. Angelopoulos" <aka(at)mvps.org> wrote in message > news:eGyRjFQzJHA.2324@TK2MSFTNGP06.phx.gbl...[color=green] >> 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@somewhere.com> wrote in message >> news:#Dg6eiEzJHA.5684@TK2MSFTNGP04.phx.gbl...[color=darkred] >>> "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: >>> >>> >>> [url]http://www.microsoft.com/technet/scriptcenter/topics/vista/indexer.mspx[/url] >>> [url]http://www.microsoft.com/technet/scriptcenter/topics/vista/wmi1.mspx[/url] >>> [url]http://msdn.microsoft.com/en-us/library/aa826600(VS.85).aspx[/url] >>> >>> 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 >>> >>>[/color][/color] > >[/color] |
| Bookmarks |
| Thread Tools | |
| |
| | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Use VBScript to Set Local Computer Description | Jeremy | Windows Vista | 19 | 06-05-2009 04:20 PM |
| Cannot ping local IP of computer. | Bryan | Windows XP | 4 | 01-09-2008 03:00 PM |
| Need to Display the "Computer Description" column (like I could in XP) | Jessi | Windows Vista | 1 | 07-31-2007 12:10 PM |
| One Computer Two local sessions | matrikas@gmail.com | Windows XP | 2 | 03-31-2007 11:15 PM |
| How do I change my computer description | Terry | Windows XP | 4 | 01-13-2007 08:00 PM |
| New To Technology Questions? | Do You Need Help with Your Computer or Device? | Do You Need Help with this site? |