![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Use VBScript to 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 Specs![]() |
| | #2 (permalink) |
| | Re: Use VBScript to Set Local Computer Description "Jeremy" <trombone79atgmail.com> wrote in message news:OjxTslzyJHA.1416@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 Does it help to specify impersonationLevel and authenticationLevel when you connect with WMI? For example: strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate,authenticationLevel=Pkt}!\\" _ & strComputer & "\root\cimv2") Also, when you say you run the script as Administrator, I assume you either right click the script and select "Run as administrator", or you run a command prompt by right clicking cmd.exe and selecting "Run as administrator". Being authenticated to the machine with administrator credentials no longer will work. Finally, which is line 6? -- Richard Mueller MVP Directory Services Hilltop Lab - http://www.rlmueller.net -- |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Use VBScript to Set Local Computer Description I run from a command prompt that I righ-click to run as administrator. There is no option in the context menu on a .vbs file. Setting the impersonationLevel=impersonate yields exactle the same result. I have tried with and without it. The error Line (line 6 in my error) is x.Put_ . Thanks for your reply. Sorry to everyone about the double post. "Richard Mueller [MVP]" <rlmueller-nospam@xxxxxx> wrote in message news:OthKXU0yJHA.1380@xxxxxx Quote: > > "Jeremy" <trombone79atgmail.com> wrote in message > news:OjxTslzyJHA.1416@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 > > Does it help to specify impersonationLevel and authenticationLevel when > you connect with WMI? For example: > > strComputer = "." > Set objWMIService = GetObject("winmgmts:" _ > & "{impersonationLevel=impersonate,authenticationLevel=Pkt}!\\" _ > & strComputer & "\root\cimv2") > > > Also, when you say you run the script as Administrator, I assume you > either right click the script and select "Run as administrator", or you > run a command prompt by right clicking cmd.exe and selecting "Run as > administrator". Being authenticated to the machine with administrator > credentials no longer will work. Finally, which is line 6? > > -- > Richard Mueller > MVP Directory Services > Hilltop Lab - http://www.rlmueller.net > -- > > |
My System Specs![]() |
| | #4 (permalink) |
| | Re: Use VBScript to Set Local Computer Description I've tried the demo code and have no trouble at all with it on Vista Business Edition (32-bit), Win 7 Beta build 7000 x64, or Win2008 Server x64. Did you try the _modified_ version on the computer, the one that simply sets the description as you showed? I'm asking because I suspect the error message could be correct with AD data in some circumstances. Depending on what you're pulling from where in AD, the value you return may not be a standard text string. If you find a generic description can be set successfully, I suggest you next look at the data you're returning from AD to use as the description. I would check two things: the typename for the returned value, and then - if it appears to be a single string - I suggest escaping the data and displaying it, to check for possible odd characters. WScript.Echo TypeName(AdDescription) WScript.Echo Escape(AdDescription) "Jeremy" <trombone79atgmail.com> wrote in message news:ubrgkk0yJHA.5684@xxxxxx Quote: > I run from a command prompt that I righ-click to run as administrator. > There is no option in the context menu on a .vbs file. > > Setting the impersonationLevel=impersonate yields exactle the same result. > I have tried with and without it. > > The error Line (line 6 in my error) is x.Put_ . > > Thanks for your reply. > > > Sorry to everyone about the double post. > > "Richard Mueller [MVP]" <rlmueller-nospam@xxxxxx> wrote in > message news:OthKXU0yJHA.1380@xxxxxx Quote: >> >> "Jeremy" <trombone79atgmail.com> wrote in message >> news:OjxTslzyJHA.1416@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 >> >> Does it help to specify impersonationLevel and authenticationLevel when >> you connect with WMI? For example: >> >> strComputer = "." >> Set objWMIService = GetObject("winmgmts:" _ >> & "{impersonationLevel=impersonate,authenticationLevel=Pkt}!\\" _ >> & strComputer & "\root\cimv2") >> >> >> Also, when you say you run the script as Administrator, I assume you >> either right click the script and select "Run as administrator", or you >> run a command prompt by right clicking cmd.exe and selecting "Run as >> administrator". Being authenticated to the machine with administrator >> credentials no longer will work. Finally, which is line 6? >> >> -- >> Richard Mueller >> MVP Directory Services >> Hilltop Lab - http://www.rlmueller.net >> -- >> >> > |
My System Specs![]() |
| | #5 (permalink) |
| | Re: Use VBScript to Set Local Computer Description The description attribute in AD is multi-valued, even though there is never more than one value. Depending on how you retrieve the value, you could get an array. For example, ADO either returns a Null if there is no value, or an array of one string value. TypeName will return "String()" in the later case. -- Richard Mueller MVP Directory Services Hilltop Lab - http://www.rlmueller.net -- "Alex K. Angelopoulos" <aka(at)mvps.org> wrote in message news:OUx%23$D4yJHA.5032@xxxxxx Quote: > I've tried the demo code and have no trouble at all with it on Vista > Business Edition (32-bit), Win 7 Beta build 7000 x64, or Win2008 Server > x64. > > Did you try the _modified_ version on the computer, the one that simply > sets the description as you showed? I'm asking because I suspect the error > message could be correct with AD data in some circumstances. Depending on > what you're pulling from where in AD, the value you return may not be a > standard text string. > > If you find a generic description can be set successfully, I suggest you > next look at the data you're returning from AD to use as the description. > I would check two things: the typename for the returned value, and then - > if it appears to be a single string - I suggest escaping the data and > displaying it, to check for possible odd characters. > > WScript.Echo TypeName(AdDescription) > WScript.Echo Escape(AdDescription) > > "Jeremy" <trombone79atgmail.com> wrote in message > news:ubrgkk0yJHA.5684@xxxxxx Quote: >> I run from a command prompt that I righ-click to run as administrator. >> There is no option in the context menu on a .vbs file. >> >> Setting the impersonationLevel=impersonate yields exactle the same >> result. I have tried with and without it. >> >> The error Line (line 6 in my error) is x.Put_ . >> >> Thanks for your reply. >> >> >> Sorry to everyone about the double post. >> >> "Richard Mueller [MVP]" <rlmueller-nospam@xxxxxx> wrote in >> message news:OthKXU0yJHA.1380@xxxxxx Quote: >>> >>> "Jeremy" <trombone79atgmail.com> wrote in message >>> news:OjxTslzyJHA.1416@xxxxxx >>>>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 >>> >>> >>> Does it help to specify impersonationLevel and authenticationLevel when >>> you connect with WMI? For example: >>> >>> strComputer = "." >>> Set objWMIService = GetObject("winmgmts:" _ >>> & "{impersonationLevel=impersonate,authenticationLevel=Pkt}!\\" _ >>> & strComputer & "\root\cimv2") >>> >>> >>> Also, when you say you run the script as Administrator, I assume you >>> either right click the script and select "Run as administrator", or you >>> run a command prompt by right clicking cmd.exe and selecting "Run as >>> administrator". Being authenticated to the machine with administrator >>> credentials no longer will work. Finally, which is line 6? >>> >>> -- >>> Richard Mueller >>> MVP Directory Services >>> Hilltop Lab - http://www.rlmueller.net >>> -- >>> >>> >> |
My System Specs![]() |
| | #6 (permalink) |
| | Re: Use VBScript to Set Local Computer Description I have attempted this as a standalone script entering simply "test" as the description using the exact code in this post with the same result. My startup script is extensive and I do many things on the computer with it. That being said, I take into account all value types returned from AD in my script(s). If you were able to run this code on Win2008 x64, it must either be a hotfix or something else specific to my environment or even the way I am running it? Alex, can you step me through the process you use to run the script? Though I am sure my process for running it is ok, I'm new to Vista/2008 and may be missing something. I start by putting the script on the desktop. I then run cmd.exe as administrator by right clicking and choosing to run as administrator. Then change my directory to the desktop folder where the ..vbs file is located. I then type the name of the file to run it. Thanks for the help "Alex K. Angelopoulos" <aka(at)mvps.org> wrote in message news:OUx%23$D4yJHA.5032@xxxxxx Quote: > I've tried the demo code and have no trouble at all with it on Vista > Business Edition (32-bit), Win 7 Beta build 7000 x64, or Win2008 Server > x64. > > Did you try the _modified_ version on the computer, the one that simply > sets the description as you showed? I'm asking because I suspect the error > message could be correct with AD data in some circumstances. Depending on > what you're pulling from where in AD, the value you return may not be a > standard text string. > > If you find a generic description can be set successfully, I suggest you > next look at the data you're returning from AD to use as the description. > I would check two things: the typename for the returned value, and then - > if it appears to be a single string - I suggest escaping the data and > displaying it, to check for possible odd characters. > > WScript.Echo TypeName(AdDescription) > WScript.Echo Escape(AdDescription) > > "Jeremy" <trombone79atgmail.com> wrote in message > news:ubrgkk0yJHA.5684@xxxxxx Quote: >> I run from a command prompt that I righ-click to run as administrator. >> There is no option in the context menu on a .vbs file. >> >> Setting the impersonationLevel=impersonate yields exactle the same >> result. I have tried with and without it. >> >> The error Line (line 6 in my error) is x.Put_ . >> >> Thanks for your reply. >> >> >> Sorry to everyone about the double post. >> >> "Richard Mueller [MVP]" <rlmueller-nospam@xxxxxx> wrote in >> message news:OthKXU0yJHA.1380@xxxxxx Quote: >>> >>> "Jeremy" <trombone79atgmail.com> wrote in message >>> news:OjxTslzyJHA.1416@xxxxxx >>>>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 >>> >>> >>> Does it help to specify impersonationLevel and authenticationLevel when >>> you connect with WMI? For example: >>> >>> strComputer = "." >>> Set objWMIService = GetObject("winmgmts:" _ >>> & "{impersonationLevel=impersonate,authenticationLevel=Pkt}!\\" _ >>> & strComputer & "\root\cimv2") >>> >>> >>> Also, when you say you run the script as Administrator, I assume you >>> either right click the script and select "Run as administrator", or you >>> run a command prompt by right clicking cmd.exe and selecting "Run as >>> administrator". Being authenticated to the machine with administrator >>> credentials no longer will work. Finally, which is line 6? >>> >>> -- >>> Richard Mueller >>> MVP Directory Services >>> Hilltop Lab - http://www.rlmueller.net >>> -- >>> >>> >> |
My System Specs![]() |
| | #7 (permalink) |
| | Re: Use VBScript to Set Local Computer Description You're running it exactly the way I do. What do you mean by same result? Same result as I get, or the same type mismatch error that you got before? "Jeremy" <trombone79atgmail.com> wrote in message news:ukMqmb4yJHA.5684@xxxxxx Quote: > I have attempted this as a standalone script entering simply "test" as the > description using the exact code in this post with the same result. > > My startup script is extensive and I do many things on the computer with > it. That being said, I take into account all value types returned from AD > in my script(s). > > If you were able to run this code on Win2008 x64, it must either be a > hotfix or something else specific to my environment or even the way I am > running it? > > Alex, can you step me through the process you use to run the script? > Though I am sure my process for running it is ok, I'm new to Vista/2008 > and may be missing something. I start by putting the script on the > desktop. I then run cmd.exe as administrator by right clicking and > choosing to run as administrator. Then change my directory to the desktop > folder where the .vbs file is located. I then type the name of the file > to run it. > > Thanks for the help > > "Alex K. Angelopoulos" <aka(at)mvps.org> wrote in message > news:OUx%23$D4yJHA.5032@xxxxxx Quote: >> I've tried the demo code and have no trouble at all with it on Vista >> Business Edition (32-bit), Win 7 Beta build 7000 x64, or Win2008 Server >> x64. >> >> Did you try the _modified_ version on the computer, the one that simply >> sets the description as you showed? I'm asking because I suspect the >> error message could be correct with AD data in some circumstances. >> Depending on what you're pulling from where in AD, the value you return >> may not be a standard text string. >> >> If you find a generic description can be set successfully, I suggest you >> next look at the data you're returning from AD to use as the description. >> I would check two things: the typename for the returned value, and then - >> if it appears to be a single string - I suggest escaping the data and >> displaying it, to check for possible odd characters. >> >> WScript.Echo TypeName(AdDescription) >> WScript.Echo Escape(AdDescription) >> >> "Jeremy" <trombone79atgmail.com> wrote in message >> news:ubrgkk0yJHA.5684@xxxxxx Quote: >>> I run from a command prompt that I righ-click to run as administrator. >>> There is no option in the context menu on a .vbs file. >>> >>> Setting the impersonationLevel=impersonate yields exactle the same >>> result. I have tried with and without it. >>> >>> The error Line (line 6 in my error) is x.Put_ . >>> >>> Thanks for your reply. >>> >>> >>> Sorry to everyone about the double post. >>> >>> "Richard Mueller [MVP]" <rlmueller-nospam@xxxxxx> wrote in >>> message news:OthKXU0yJHA.1380@xxxxxx >>>> >>>> "Jeremy" <trombone79atgmail.com> wrote in message >>>> news:OjxTslzyJHA.1416@xxxxxx >>>>>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 >>>> >>>> >>>> Does it help to specify impersonationLevel and authenticationLevel when >>>> you connect with WMI? For example: >>>> >>>> strComputer = "." >>>> Set objWMIService = GetObject("winmgmts:" _ >>>> & "{impersonationLevel=impersonate,authenticationLevel=Pkt}!\\" _ >>>> & strComputer & "\root\cimv2") >>>> >>>> >>>> Also, when you say you run the script as Administrator, I assume you >>>> either right click the script and select "Run as administrator", or you >>>> run a command prompt by right clicking cmd.exe and selecting "Run as >>>> administrator". Being authenticated to the machine with administrator >>>> credentials no longer will work. Finally, which is line 6? >>>> >>>> -- >>>> Richard Mueller >>>> MVP Directory Services >>>> Hilltop Lab - http://www.rlmueller.net >>>> -- >>>> >>>> >>> >>> > |
My System Specs![]() |
| | #8 (permalink) |
| | Re: Use VBScript to Set Local Computer Description Ignore my previous post. I can confirm that on Vista 32-bit I get the same error as you do IF the description has already been set to some value: Error: Value out of range Code: 8004102B Source: SWbemObjectEx So I can confirm it's apparently an issue with doing a put_ in the environment when a value is already set, and it appears to happen on 32-bit Vista as well - but not 64-bit Vista or 2008 Server. I've tried running the test following a reboot and get the same error back. I initially tried setting some flags on the Put_() method but Vista doesn't appear to like that. What's weird is the error that we get back; it's not only undocumented in the Put_ method docs, but when it _has_ been reported in the past (on XP) it has been a meaningful message - people trying to create a page file that's too large, for example. I'm trying to find a way to look inside the problem now. "Alex K. Angelopoulos" <aka(at)mvps.org> wrote in message news:eEOQlk#yJHA.4412@xxxxxx Quote: > You're running it exactly the way I do. What do you mean by same result? > Same result as I get, or the same type mismatch error that you got before? > > "Jeremy" <trombone79atgmail.com> wrote in message > news:ukMqmb4yJHA.5684@xxxxxx Quote: >> I have attempted this as a standalone script entering simply "test" as >> the description using the exact code in this post with the same result. >> >> My startup script is extensive and I do many things on the computer with >> it. That being said, I take into account all value types returned from AD >> in my script(s). >> >> If you were able to run this code on Win2008 x64, it must either be a >> hotfix or something else specific to my environment or even the way I am >> running it? >> >> Alex, can you step me through the process you use to run the script? >> Though I am sure my process for running it is ok, I'm new to Vista/2008 >> and may be missing something. I start by putting the script on the >> desktop. I then run cmd.exe as administrator by right clicking and >> choosing to run as administrator. Then change my directory to the >> desktop folder where the .vbs file is located. I then type the name of >> the file to run it. >> >> Thanks for the help >> >> "Alex K. Angelopoulos" <aka(at)mvps.org> wrote in message >> news:OUx%23$D4yJHA.5032@xxxxxx Quote: >>> I've tried the demo code and have no trouble at all with it on Vista >>> Business Edition (32-bit), Win 7 Beta build 7000 x64, or Win2008 Server >>> x64. >>> >>> Did you try the _modified_ version on the computer, the one that simply >>> sets the description as you showed? I'm asking because I suspect the >>> error message could be correct with AD data in some circumstances. >>> Depending on what you're pulling from where in AD, the value you return >>> may not be a standard text string. >>> >>> If you find a generic description can be set successfully, I suggest you >>> next look at the data you're returning from AD to use as the >>> description. I would check two things: the typename for the returned >>> value, and then - if it appears to be a single string - I suggest >>> escaping the data and displaying it, to check for possible odd >>> characters. >>> >>> WScript.Echo TypeName(AdDescription) >>> WScript.Echo Escape(AdDescription) >>> >>> "Jeremy" <trombone79atgmail.com> wrote in message >>> news:ubrgkk0yJHA.5684@xxxxxx >>>> I run from a command prompt that I righ-click to run as administrator. >>>> There is no option in the context menu on a .vbs file. >>>> >>>> Setting the impersonationLevel=impersonate yields exactle the same >>>> result. I have tried with and without it. >>>> >>>> The error Line (line 6 in my error) is x.Put_ . >>>> >>>> Thanks for your reply. >>>> >>>> >>>> Sorry to everyone about the double post. >>>> >>>> "Richard Mueller [MVP]" <rlmueller-nospam@xxxxxx> wrote >>>> in message news:OthKXU0yJHA.1380@xxxxxx >>>>> >>>>> "Jeremy" <trombone79atgmail.com> wrote in message >>>>> news:OjxTslzyJHA.1416@xxxxxx >>>>>>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 >>>>> >>>>> >>>>> Does it help to specify impersonationLevel and authenticationLevel >>>>> when you connect with WMI? For example: >>>>> >>>>> strComputer = "." >>>>> Set objWMIService = GetObject("winmgmts:" _ >>>>> & "{impersonationLevel=impersonate,authenticationLevel=Pkt}!\\" _ >>>>> & strComputer & "\root\cimv2") >>>>> >>>>> >>>>> Also, when you say you run the script as Administrator, I assume you >>>>> either right click the script and select "Run as administrator", or >>>>> you run a command prompt by right clicking cmd.exe and selecting "Run >>>>> as administrator". Being authenticated to the machine with >>>>> administrator credentials no longer will work. Finally, which is line >>>>> 6? >>>>> >>>>> -- >>>>> Richard Mueller >>>>> MVP Directory Services >>>>> Hilltop Lab - http://www.rlmueller.net >>>>> -- >>>>> >>>>> >>>> >>>> >> |
My System Specs![]() |
| | #9 (permalink) |
| | Re: Use VBScript to Set Local Computer Description I'm getting nothing useful from trying to explore the Description property. I _do_ have a workaround for this specific scenario; you can set a computer's description either locally or remotely by directly going to the registry value backing it. It works fine using WMI's StdRegProv. Unfortunately, it doesn't explain why this particular problem happens. strComputer = "." Set reg = GetObject("winmgmts:\\"&_ strComputer & "\root\default:StdRegProv") regpath = "SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters" value = "New Description for the computer" returned = reg.SetStringValue( &H80000002, regpath, "srvcomment", value) WScript.Echo returned ' returned error, which should be 0 "Alex K. Angelopoulos" <aka(at)mvps.org> wrote in message news:ecRKI5#yJHA.4272@xxxxxx Quote: > Ignore my previous post. I can confirm that on Vista 32-bit I get the same > error as you do IF the description has already been set to some value: > Error: Value out of range > Code: 8004102B > Source: SWbemObjectEx > > So I can confirm it's apparently an issue with doing a put_ in the > environment when a value is already set, and it appears to happen on > 32-bit Vista as well - but not 64-bit Vista or 2008 Server. I've tried > running the test following a reboot and get the same error back. > > I initially tried setting some flags on the Put_() method but Vista > doesn't appear to like that. What's weird is the error that we get back; > it's not only undocumented in the Put_ method docs, but when it _has_ been > reported in the past (on XP) it has been a meaningful message - people > trying to create a page file that's too large, for example. > > I'm trying to find a way to look inside the problem now. > > > > "Alex K. Angelopoulos" <aka(at)mvps.org> wrote in message > news:eEOQlk#yJHA.4412@xxxxxx Quote: >> You're running it exactly the way I do. What do you mean by same result? >> Same result as I get, or the same type mismatch error that you got >> before? >> >> "Jeremy" <trombone79atgmail.com> wrote in message >> news:ukMqmb4yJHA.5684@xxxxxx Quote: >>> I have attempted this as a standalone script entering simply "test" as >>> the description using the exact code in this post with the same result. >>> >>> My startup script is extensive and I do many things on the computer with >>> it. That being said, I take into account all value types returned from >>> AD in my script(s). >>> >>> If you were able to run this code on Win2008 x64, it must either be a >>> hotfix or something else specific to my environment or even the way I am >>> running it? >>> >>> Alex, can you step me through the process you use to run the script? >>> Though I am sure my process for running it is ok, I'm new to Vista/2008 >>> and may be missing something. I start by putting the script on the >>> desktop. I then run cmd.exe as administrator by right clicking and >>> choosing to run as administrator. Then change my directory to the >>> desktop folder where the .vbs file is located. I then type the name of >>> the file to run it. >>> >>> Thanks for the help >>> >>> "Alex K. Angelopoulos" <aka(at)mvps.org> wrote in message >>> news:OUx%23$D4yJHA.5032@xxxxxx >>>> I've tried the demo code and have no trouble at all with it on Vista >>>> Business Edition (32-bit), Win 7 Beta build 7000 x64, or Win2008 Server >>>> x64. >>>> >>>> Did you try the _modified_ version on the computer, the one that simply >>>> sets the description as you showed? I'm asking because I suspect the >>>> error message could be correct with AD data in some circumstances. >>>> Depending on what you're pulling from where in AD, the value you return >>>> may not be a standard text string. >>>> >>>> If you find a generic description can be set successfully, I suggest >>>> you next look at the data you're returning from AD to use as the >>>> description. I would check two things: the typename for the returned >>>> value, and then - if it appears to be a single string - I suggest >>>> escaping the data and displaying it, to check for possible odd >>>> characters. >>>> >>>> WScript.Echo TypeName(AdDescription) >>>> WScript.Echo Escape(AdDescription) >>>> >>>> "Jeremy" <trombone79atgmail.com> wrote in message >>>> news:ubrgkk0yJHA.5684@xxxxxx >>>>> I run from a command prompt that I righ-click to run as administrator. >>>>> There is no option in the context menu on a .vbs file. >>>>> >>>>> Setting the impersonationLevel=impersonate yields exactle the same >>>>> result. I have tried with and without it. >>>>> >>>>> The error Line (line 6 in my error) is x.Put_ . >>>>> >>>>> Thanks for your reply. >>>>> >>>>> >>>>> Sorry to everyone about the double post. >>>>> >>>>> "Richard Mueller [MVP]" <rlmueller-nospam@xxxxxx> wrote >>>>> in message news:OthKXU0yJHA.1380@xxxxxx >>>>>> >>>>>> "Jeremy" <trombone79atgmail.com> wrote in message >>>>>> news:OjxTslzyJHA.1416@xxxxxx >>>>>>>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 >>>>>> >>>>>> >>>>>> Does it help to specify impersonationLevel and authenticationLevel >>>>>> when you connect with WMI? For example: >>>>>> >>>>>> strComputer = "." >>>>>> Set objWMIService = GetObject("winmgmts:" _ >>>>>> & "{impersonationLevel=impersonate,authenticationLevel=Pkt}!\\" _ >>>>>> & strComputer & "\root\cimv2") >>>>>> >>>>>> >>>>>> Also, when you say you run the script as Administrator, I assume you >>>>>> either right click the script and select "Run as administrator", or >>>>>> you run a command prompt by right clicking cmd.exe and selecting "Run >>>>>> as administrator". Being authenticated to the machine with >>>>>> administrator credentials no longer will work. Finally, which is line >>>>>> 6? >>>>>> >>>>>> -- >>>>>> Richard Mueller >>>>>> MVP Directory Services >>>>>> Hilltop Lab - http://www.rlmueller.net >>>>>> -- >>>>>> >>>>>> >>>>> >>>>> >>> >>> |
My System Specs![]() |
| | #10 (permalink) |
| | Re: Use VBScript to Set Local Computer Description And one more self-spamming post. ; ) I'm finding the error occurs with the Put_() method against other WMI properties on Vista x86. I also tried disabling UAC temporarily, and even enabling the standard administrator account and logging in with it. Same results. I went on to try using CIM_OperatingSystem instead of Win32_OperatingSystem, and get the same error value back. I'm not finding any reports of this specific issue with Vista, however. "Alex K. Angelopoulos" <aka(at)mvps.org> wrote in message news:ecRKI5#yJHA.4272@xxxxxx Quote: > Ignore my previous post. I can confirm that on Vista 32-bit I get the same > error as you do IF the description has already been set to some value: > Error: Value out of range > Code: 8004102B > Source: SWbemObjectEx > > So I can confirm it's apparently an issue with doing a put_ in the > environment when a value is already set, and it appears to happen on > 32-bit Vista as well - but not 64-bit Vista or 2008 Server. I've tried > running the test following a reboot and get the same error back. > > I initially tried setting some flags on the Put_() method but Vista > doesn't appear to like that. What's weird is the error that we get back; > it's not only undocumented in the Put_ method docs, but when it _has_ been > reported in the past (on XP) it has been a meaningful message - people > trying to create a page file that's too large, for example. > > I'm trying to find a way to look inside the problem now. > > > > "Alex K. Angelopoulos" <aka(at)mvps.org> wrote in message > news:eEOQlk#yJHA.4412@xxxxxx Quote: >> You're running it exactly the way I do. What do you mean by same result? >> Same result as I get, or the same type mismatch error that you got >> before? >> >> "Jeremy" <trombone79atgmail.com> wrote in message >> news:ukMqmb4yJHA.5684@xxxxxx Quote: >>> I have attempted this as a standalone script entering simply "test" as >>> the description using the exact code in this post with the same result. >>> >>> My startup script is extensive and I do many things on the computer with >>> it. That being said, I take into account all value types returned from >>> AD in my script(s). >>> >>> If you were able to run this code on Win2008 x64, it must either be a >>> hotfix or something else specific to my environment or even the way I am >>> running it? >>> >>> Alex, can you step me through the process you use to run the script? >>> Though I am sure my process for running it is ok, I'm new to Vista/2008 >>> and may be missing something. I start by putting the script on the >>> desktop. I then run cmd.exe as administrator by right clicking and >>> choosing to run as administrator. Then change my directory to the >>> desktop folder where the .vbs file is located. I then type the name of >>> the file to run it. >>> >>> Thanks for the help >>> >>> "Alex K. Angelopoulos" <aka(at)mvps.org> wrote in message >>> news:OUx%23$D4yJHA.5032@xxxxxx >>>> I've tried the demo code and have no trouble at all with it on Vista >>>> Business Edition (32-bit), Win 7 Beta build 7000 x64, or Win2008 Server >>>> x64. >>>> >>>> Did you try the _modified_ version on the computer, the one that simply >>>> sets the description as you showed? I'm asking because I suspect the >>>> error message could be correct with AD data in some circumstances. >>>> Depending on what you're pulling from where in AD, the value you return >>>> may not be a standard text string. >>>> >>>> If you find a generic description can be set successfully, I suggest >>>> you next look at the data you're returning from AD to use as the >>>> description. I would check two things: the typename for the returned >>>> value, and then - if it appears to be a single string - I suggest >>>> escaping the data and displaying it, to check for possible odd >>>> characters. >>>> >>>> WScript.Echo TypeName(AdDescription) >>>> WScript.Echo Escape(AdDescription) >>>> >>>> "Jeremy" <trombone79atgmail.com> wrote in message >>>> news:ubrgkk0yJHA.5684@xxxxxx >>>>> I run from a command prompt that I righ-click to run as administrator. >>>>> There is no option in the context menu on a .vbs file. >>>>> >>>>> Setting the impersonationLevel=impersonate yields exactle the same >>>>> result. I have tried with and without it. >>>>> >>>>> The error Line (line 6 in my error) is x.Put_ . >>>>> >>>>> Thanks for your reply. >>>>> >>>>> >>>>> Sorry to everyone about the double post. >>>>> >>>>> "Richard Mueller [MVP]" <rlmueller-nospam@xxxxxx> wrote >>>>> in message news:OthKXU0yJHA.1380@xxxxxx >>>>>> >>>>>> "Jeremy" <trombone79atgmail.com> wrote in message >>>>>> news:OjxTslzyJHA.1416@xxxxxx >>>>>>>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 >>>>>> >>>>>> >>>>>> Does it help to specify impersonationLevel and authenticationLevel >>>>>> when you connect with WMI? For example: >>>>>> >>>>>> strComputer = "." >>>>>> Set objWMIService = GetObject("winmgmts:" _ >>>>>> & "{impersonationLevel=impersonate,authenticationLevel=Pkt}!\\" _ >>>>>> & strComputer & "\root\cimv2") >>>>>> >>>>>> >>>>>> Also, when you say you run the script as Administrator, I assume you >>>>>> either right click the script and select "Run as administrator", or >>>>>> you run a command prompt by right clicking cmd.exe and selecting "Run >>>>>> as administrator". Being authenticated to the machine with >>>>>> administrator credentials no longer will work. Finally, which is line >>>>>> 6? >>>>>> >>>>>> -- >>>>>> Richard Mueller >>>>>> MVP Directory Services >>>>>> Hilltop Lab - http://www.rlmueller.net >>>>>> -- >>>>>> >>>>>> >>>>> >>>>> >>> >>> |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Use VBScript to Set Local Computer Description | Vista General | |||
| How to edit the description of shares using command-line or vbscript? | VB Script | |||
| Set Local Computer Description | VB Script | |||
| Re: Set Local Computer Description | Vista General | |||
| Computer description in Network places | Vista networking & sharing | |||