![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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) |
| | VBScript to get the Dell Service Tag.....I know...I know.... Good morning! I am going to post the script that I am using below. I have run this in several environments on Dell PowerEdge Servers and all I get is the "--------------------------------" part. I have literally copied from the Internet.....written it myself from scratch.....used both "WIN32_BIOS" and "WIN32_SystemEnclosure"...same results on both. Does anyone see anything incorrect with this script: '================================================================================================== ' ' VBScript Source File ' ' NAME: SerialNumber1.VBS ' VERSION: 1.0 ' CREATE DATE : 05/31/2009 ' LAST MODIFIED : n/a '================================================================================================== ' COMMENT: This script will list the Dell Service Tag '================================================================================================== Option Explicit On Error Resume Next Dim objWMIService, colSMBIOS, objSMBIOS Dim strComputer strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colSMBIOS = objWMIService.ExecQuery ("SELECT * FROM WIN32_BIOS,,48") For Each objSMBIOS in colSMBIOS Wscript.Echo "Dell Service Tag: " & objSMBIOS.SerialNumber Wscript.Echo "----------------------------------------------" Next Thanks, Cary PS....using wmic on the system locally does produce the correct results |
My System Specs![]() |
| | #2 (permalink) |
| | Re: VBScript to get the Dell Service Tag.....I know...I know.... "Cary Shultz" <cshultz@xxxxxx> wrote in message news:u$3bce35JHA.480@xxxxxx Quote: > Good morning! > > I am going to post the script that I am using below. I have run this in > several environments on Dell PowerEdge Servers and all I get is the > "--------------------------------" part. I have literally copied from the > Internet.....written it myself from scratch.....used both "WIN32_BIOS" and > "WIN32_SystemEnclosure"...same results on both. Does anyone see anything > incorrect with this script: > > > '================================================================================================== > ' > ' VBScript Source File > ' > ' NAME: SerialNumber1.VBS > ' VERSION: 1.0 > ' CREATE DATE : 05/31/2009 > ' LAST MODIFIED : n/a > '================================================================================================== > ' COMMENT: This script will list the Dell Service Tag > '================================================================================================== > > Option Explicit > On Error Resume Next > > Dim objWMIService, colSMBIOS, objSMBIOS > Dim strComputer > > strComputer = "." > > Set objWMIService = GetObject("winmgmts:" _ > & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") > Set colSMBIOS = objWMIService.ExecQuery ("SELECT * FROM WIN32_BIOS,,48") > > > For Each objSMBIOS in colSMBIOS > Wscript.Echo "Dell Service Tag: " & objSMBIOS.SerialNumber > Wscript.Echo "----------------------------------------------" > Next > > > > > Thanks, > > Cary > > PS....using wmic on the system locally does produce the correct results "On Error Resume Next". Get rid of it! |
My System Specs![]() |
| | #3 (permalink) |
| | Re: VBScript to get the Dell Service Tag.....I know...I know.... Pegasus, Sorry....should have included in the original post that I have done with "On Error Resume Next" and without. With - all I get is the "-----------------------------------------------" part. Without - I get the following notification: SerialNumber1.vbs(28,6) (null): 0x80041017 I have also 'removed' the 'Option Explicit' and 'On Error Resume Next' and 'Dim This' and 'Dim That'....just ran the script...same results. Additionally, I have changed the colSMBIOS and objSMBIOS to simply 'colItems' and 'objItem'......same results. Bad on me for not including this in the original post. I am just getting frustrated......Thanks for calling me out on that, Pegasus. I know better! I am not in here for the first time! I did look this up (one or two days ago) and the 80041017 tells me that the query is wrong? Not so sure about that! But, clearly I am missing something. I - like I said - have run this is several environments (my Virtual PC, a test environment and several production environments). I have been logged on as different users. Same thing everytime (with 'On Error Resume Next' all I get is the "--------------------------------------------------" part......without 'On Error Resume Next' I receive the 80041017 error). Anyway, any help would be appreciated. BTW - getting the same error with the same script - only looking for the Dell Model........replace "WIN32_BIOS" / "WIN32_SystemEnclosure" with "WIN32_ComputerSystem" and "objXXXX.SerialNumber" with "objXXXXX.Model"... "Pegasus [MVP]" <news@xxxxxx> wrote in message news:OKPx8u35JHA.1712@xxxxxx Quote: > > "Cary Shultz" <cshultz@xxxxxx> wrote in message > news:u$3bce35JHA.480@xxxxxx Quote: >> Good morning! >> >> I am going to post the script that I am using below. I have run this in >> several environments on Dell PowerEdge Servers and all I get is the >> "--------------------------------" part. I have literally copied from >> the Internet.....written it myself from scratch.....used both >> "WIN32_BIOS" and "WIN32_SystemEnclosure"...same results on both. Does >> anyone see anything incorrect with this script: >> >> >> '================================================================================================== >> ' >> ' VBScript Source File >> ' >> ' NAME: SerialNumber1.VBS >> ' VERSION: 1.0 >> ' CREATE DATE : 05/31/2009 >> ' LAST MODIFIED : n/a >> '================================================================================================== >> ' COMMENT: This script will list the Dell Service Tag >> '================================================================================================== >> >> Option Explicit >> On Error Resume Next >> >> Dim objWMIService, colSMBIOS, objSMBIOS >> Dim strComputer >> >> strComputer = "." >> >> Set objWMIService = GetObject("winmgmts:" _ >> & "{impersonationLevel=impersonate}!\\" & strComputer & >> "\root\cimv2") >> Set colSMBIOS = objWMIService.ExecQuery ("SELECT * FROM WIN32_BIOS,,48") >> >> >> For Each objSMBIOS in colSMBIOS >> Wscript.Echo "Dell Service Tag: " & objSMBIOS.SerialNumber >> Wscript.Echo "----------------------------------------------" >> Next >> >> >> >> >> Thanks, >> >> Cary >> >> PS....using wmic on the system locally does produce the correct results > There might be some access error, which you are hiding with the statement > "On Error Resume Next". Get rid of it! > |
My System Specs![]() |
| | #4 (permalink) |
| | Re: VBScript to get the Dell Service Tag.....I know...I know.... Pegasus.... Look at my query, please! Pay particular attention to the ,,48 part.......what do you see after the '48'? What do you *NOT* see in front of the ',,48'? Query is incorrect.....that was the tip off that - in my frustration - I simply did not see. I just did! The query is indeed incorrect. I resolved it and it worked! Imagine that! Both of them - the WIN32_BIOS and the WIN32_ComputerSystem..... That was a huge "DOH!" on my part. Sorry for wasting everyone's time! "Pegasus [MVP]" <news@xxxxxx> wrote in message news:OKPx8u35JHA.1712@xxxxxx Quote: > > "Cary Shultz" <cshultz@xxxxxx> wrote in message > news:u$3bce35JHA.480@xxxxxx Quote: >> Good morning! >> >> I am going to post the script that I am using below. I have run this in >> several environments on Dell PowerEdge Servers and all I get is the >> "--------------------------------" part. I have literally copied from >> the Internet.....written it myself from scratch.....used both >> "WIN32_BIOS" and "WIN32_SystemEnclosure"...same results on both. Does >> anyone see anything incorrect with this script: >> >> >> '================================================================================================== >> ' >> ' VBScript Source File >> ' >> ' NAME: SerialNumber1.VBS >> ' VERSION: 1.0 >> ' CREATE DATE : 05/31/2009 >> ' LAST MODIFIED : n/a >> '================================================================================================== >> ' COMMENT: This script will list the Dell Service Tag >> '================================================================================================== >> >> Option Explicit >> On Error Resume Next >> >> Dim objWMIService, colSMBIOS, objSMBIOS >> Dim strComputer >> >> strComputer = "." >> >> Set objWMIService = GetObject("winmgmts:" _ >> & "{impersonationLevel=impersonate}!\\" & strComputer & >> "\root\cimv2") >> Set colSMBIOS = objWMIService.ExecQuery ("SELECT * FROM WIN32_BIOS,,48") >> >> >> For Each objSMBIOS in colSMBIOS >> Wscript.Echo "Dell Service Tag: " & objSMBIOS.SerialNumber >> Wscript.Echo "----------------------------------------------" >> Next >> >> >> >> >> Thanks, >> >> Cary >> >> PS....using wmic on the system locally does produce the correct results > There might be some access error, which you are hiding with the statement > "On Error Resume Next". Get rid of it! > |
My System Specs![]() |
| | #5 (permalink) |
| | Re: VBScript to get the Dell Service Tag.....I know...I know.... "Cary Shultz" <cshultz@xxxxxx> wrote in message news:%23DNEYi45JHA.1420@xxxxxx Quote: > Pegasus.... > > Look at my query, please! > > Pay particular attention to the ,,48 part.......what do you see after the > '48'? What do you *NOT* see in front of the ',,48'? > > Query is incorrect.....that was the tip off that - in my frustration - I > simply did not see. I just did! The query is indeed incorrect. I > resolved it and it worked! Imagine that! > > Both of them - the WIN32_BIOS and the WIN32_ComputerSystem..... > > That was a huge "DOH!" on my part. Sorry for wasting everyone's time! on the system locally does produce the correct results" which suggests that the script ran perfectly well on your local machine. Was it perhaps not the same script you used? |
My System Specs![]() |
| | #6 (permalink) |
| | Re: VBScript to get the Dell Service Tag.....I know...I know.... Pegasus, The script that I used in multiple locations is indeed the same that I posted. The error was that the " was in the incorrect location (can not believe that I did that!). When I used wmic I simply - from the cmd prompt - entered wmic and two or three other words of code.... Cary "Pegasus [MVP]" <news@xxxxxx> wrote in message news:uX041s45JHA.3856@xxxxxx Quote: > > "Cary Shultz" <cshultz@xxxxxx> wrote in message > news:%23DNEYi45JHA.1420@xxxxxx Quote: >> Pegasus.... >> >> Look at my query, please! >> >> Pay particular attention to the ,,48 part.......what do you see after the >> '48'? What do you *NOT* see in front of the ',,48'? >> >> Query is incorrect.....that was the tip off that - in my frustration - I >> simply did not see. I just did! The query is indeed incorrect. I >> resolved it and it worked! Imagine that! >> >> Both of them - the WIN32_BIOS and the WIN32_ComputerSystem..... >> >> That was a huge "DOH!" on my part. Sorry for wasting everyone's time! > Thanks for the feedback. What puzzles me is your initial claim "using wmic > on the system locally does produce the correct results" which suggests > that the script ran perfectly well on your local machine. Was it perhaps > not the same script you used? > |
My System Specs![]() |
| | #7 (permalink) |
| | Re: VBScript to get the Dell Service Tag.....I know...I know.... "Cary Shultz" <cshultz@xxxxxx> wrote in message news:u$3bce35JHA.480@xxxxxx Quote: > Good morning! > > I am going to post the script that I am using below. I have run this in > several environments on Dell PowerEdge Servers and all I get is the > "--------------------------------" part. I have literally copied from the > Internet.....written it myself from scratch.....used both "WIN32_BIOS" and > "WIN32_SystemEnclosure"...same results on both. Does anyone see anything > incorrect with this script: > > > '================================================================================================== > ' > ' VBScript Source File > ' > ' NAME: SerialNumber1.VBS > ' VERSION: 1.0 > ' CREATE DATE : 05/31/2009 > ' LAST MODIFIED : n/a > '================================================================================================== > ' COMMENT: This script will list the Dell Service Tag > '================================================================================================== > > Option Explicit > On Error Resume Next > > Dim objWMIService, colSMBIOS, objSMBIOS > Dim strComputer > > strComputer = "." > > Set objWMIService = GetObject("winmgmts:" _ > & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") > Set colSMBIOS = objWMIService.ExecQuery ("SELECT * FROM WIN32_BIOS,,48") > > > For Each objSMBIOS in colSMBIOS > Wscript.Echo "Dell Service Tag: " & objSMBIOS.SerialNumber > Wscript.Echo "----------------------------------------------" > Next > > > > > Thanks, > > Cary > > PS....using wmic on the system locally does produce the correct results works fine using: Set colSMBIOS = objWMIService.ExecQuery("SELECT * FROM WIN32_BIOS") I've never included the optional parameters with ExecQuery, so I had to look them up. In this case, 48 means a combination of wbemFlagReturnImmediately (decimal 16) and wbemFlagForwardOnly (decimal 32). It makes the query more efficient by specifying a forward only enumerator, but the collection can only be numerated once (which is fine in almost all cases anyway). Your problem is that it is a parameter of ExecQuery, not the WQL query. The quotes should enclose just the query, and the other two parameters are not in quotes. For example: Set colSMBIOS = objWMIService.ExecQuery("SELECT * FROM WIN32_BIOS", ,48) Works fine. -- Richard Mueller MVP Directory Services Hilltop Lab - http://www.rlmueller.net -- |
My System Specs![]() |
| | #8 (permalink) |
| | Re: VBScript to get the Dell Service Tag.....I know...I know.... RIchard, As always, appreciate your input. I had a brainfart on this and - as mentioned - included the ',,48' within the quotation marks. Clearly incorrect and I simply did not notice that. I have written a ton WMI scripts and - to be honest - am embarrassed that I (A) did it and (B) did not notice sooner. I usually do not use the On Error Resume Next. Just something that I turn on and turn off when testing a script that I write for the first time. As always, thanks! Cary "Richard Mueller [MVP]" <rlmueller-nospam@xxxxxx> wrote in message news:uF8kX955JHA.4892@xxxxxx Quote: > > "Cary Shultz" <cshultz@xxxxxx> wrote in message > news:u$3bce35JHA.480@xxxxxx Quote: >> Good morning! >> >> I am going to post the script that I am using below. I have run this in >> several environments on Dell PowerEdge Servers and all I get is the >> "--------------------------------" part. I have literally copied from >> the Internet.....written it myself from scratch.....used both >> "WIN32_BIOS" and "WIN32_SystemEnclosure"...same results on both. Does >> anyone see anything incorrect with this script: >> >> >> '================================================================================================== >> ' >> ' VBScript Source File >> ' >> ' NAME: SerialNumber1.VBS >> ' VERSION: 1.0 >> ' CREATE DATE : 05/31/2009 >> ' LAST MODIFIED : n/a >> '================================================================================================== >> ' COMMENT: This script will list the Dell Service Tag >> '================================================================================================== >> >> Option Explicit >> On Error Resume Next >> >> Dim objWMIService, colSMBIOS, objSMBIOS >> Dim strComputer >> >> strComputer = "." >> >> Set objWMIService = GetObject("winmgmts:" _ >> & "{impersonationLevel=impersonate}!\\" & strComputer & >> "\root\cimv2") >> Set colSMBIOS = objWMIService.ExecQuery ("SELECT * FROM WIN32_BIOS,,48") >> >> >> For Each objSMBIOS in colSMBIOS >> Wscript.Echo "Dell Service Tag: " & objSMBIOS.SerialNumber >> Wscript.Echo "----------------------------------------------" >> Next >> >> >> >> >> Thanks, >> >> Cary >> >> PS....using wmic on the system locally does produce the correct results > As noted, you should not use "On Error Resume Next". In this case, the > query works fine using: > > Set colSMBIOS = objWMIService.ExecQuery("SELECT * FROM WIN32_BIOS") > > I've never included the optional parameters with ExecQuery, so I had to > look them up. In this case, 48 means a combination of > wbemFlagReturnImmediately (decimal 16) and wbemFlagForwardOnly (decimal > 32). It makes the query more efficient by specifying a forward only > enumerator, but the collection can only be numerated once (which is fine > in almost all cases anyway). Your problem is that it is a parameter of > ExecQuery, not the WQL query. The quotes should enclose just the query, > and the other two parameters are not in quotes. For example: > > Set colSMBIOS = objWMIService.ExecQuery("SELECT * FROM WIN32_BIOS", ,48) > > Works fine. > > -- > Richard Mueller > MVP Directory Services > Hilltop Lab - http://www.rlmueller.net > -- > > |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| VBScript Runtime Error 800A0046 Dell 944 Printer Software/Driver | Vista performance & maintenance | |||
| VBScript Runtime Error 800A0046 Dell 944 Printer Software/Driver | Vista security | |||
| VBScript Runtime Error 800A0046 Dell 944 Printer Software/Driver | Vista General | |||
| VBScript Runtime Error 800A0046 Dell 944 Printer Software/Driver I | Vista installation & setup | |||
| VBScript Runtime Error 800A0046 Dell 944 Printer Software/Driver | Vista hardware & devices | |||