Retrieve Windows Product Key

Change Page: < 12 | Showing page 2 of 2, messages 41 to 46 of 46
Author Message
mbouchard
  • Total Posts : 2110
  • Scores: 29
  • Reward points : 0
  • Joined: 5/15/2003
  • Location: USA
RE: Retrieve Windows Product Key - Wednesday, September 03, 2008 11:12 PM
0
The error you are getting means that you have arrDPID dimmed twice.  If you are only using it in the function, remove the dim at the top of the script.  If you are using it in both places, remove the dim from the function.
Mike

For useful Scripting links see the Read Me First stickey!

Always remember Search is your friend.

fletchjake
  • Total Posts : 1
  • Scores: 0
  • Reward points : 0
  • Joined: 11/7/2008
RE: Retrieve Windows Product Key - Friday, November 07, 2008 9:16 AM
0
Hi,
This is a great script, I am ENTIRELY new to VB so I am lost...I got it running pulled my windows product id from the domain and all is good that way.

I have a couple questions though:

1.  I can't get it to work so I can pull the office, visio, or other MS product id's?  Anyone able to help?  I am using the script below: 
2.  I also want to see if this can go to a csv file or excel? 

'  ##########################################
'  #            #
'  #  VBScript to Retrieve a List of Computers from Active  #
'  #  Directory, check connectivity and generate a report file #
'  #  containing Microsoft Windows Licensing Information.  #
'  #            #
'  ##########################################
'
Dim objDomain, strComputer, strADComputer, PC, strKeyPath, strValueName, oReg
Dim ADCompList, ActiveCompList, RetrievedKeys
Dim IE, oFSO, objShell, strPath, objFile
Set IE = CreateObject("InternetExplorer.Application")
Set objShell = CreateObject("Wscript.Shell")
strPath = Wscript.ScriptFullName
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile(strPath)
strPath = objFSO.GetParentFolderName(objFile)
With IE
.left=200
.top=200
.height=140
.width=250
.menubar=0
.toolbar=0
.statusBar=0
.navigate "About:Blank"
.visible=1
End With
'wait a while until IE as finished to load
Do while IE.busy
loop
With IE.document
.Open
.WriteLn "<html>"
.WriteLn "<head>"
.WriteLn "<HTA:APPLICATION "
.WriteLn "     ID='objNoTitleBar'"
.WriteLn "     CAPTION=no"
.WriteLn "     SHOWINTASKBAR='NO'"
.WriteLn "     BORDER='NONE'"
.WriteLn "     APPLICATIONNAME='Please Wait'"
.WriteLn "     SCROLL='AUTO'"
.WriteLn "     SINGLEINSTANCE='yes'"
.WriteLn ">"
.WriteLn "</head>"
.WriteLn "<body text='#ffffff' bgcolor='#000000'>"
.WriteLn "<center>Please Wait....<br /><br />"
.WriteLn "<img src='" & strPath & "\ajax-loader.gif' /></center>"
.WriteLn "</body>"
.WriteLn "</html>"
.Close
End With
ADCompList = Array(0)
' Connect to root of domain
Dim rootDSE, domainContainer
Set rootDSE = GetObject("LDAP://RootDSE")
domainContainer = rootDSE.Get("defaultNamingContext")
Set ObjDomain = GetObject("LDAP://" & domainContainer)
' Enumerate through the domain
WorkWithObject(ObjDomain)
Sub WorkWithObject(oContainer)
Dim oADObject
For Each oADObject in oContainer
Select Case oADObject.Class
Case "computer"
Dim strADComputer
strADComputer = oADObject.cn
ADCompList(UBound(ADCompList)) = strADComputer
ReDim Preserve ADCompList(UBound(ADCompList) + 1)
Case "organizationalUnit" , "container"
WorkWithObject(oADObject)
End Select
Next
End Sub
ReDim Preserve ADCompList(UBound(ADCompList) - 1)
ActiveCompList = Array(0)
For Each PC In ADCompList
If Reachable(PC) Then
ActiveCompList(UBound(ActiveCompList)) = PC
ReDim Preserve ActiveCompList(UBound(ActiveCompList) + 1)
End If
Next
ReDim Preserve ActiveCompList(UBound(ActiveCompList) - 1)
Set objXMLDoc = CreateObject("Microsoft.XMLDOM")
Set rootEl = objXMLDoc.createElement("Computers")
objXMLDoc.appendChild rootEl
Dim objCurrNode, objNewNode, objNewText
' <--------------- Open Registry Key and populate binary data into an array -------------------------->
const HKEY_LOCAL_MACHINE = &H80000002
strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion"
strValueName = "DigitalProductId"
Dim iValues()
On Error Resume Next
For Each strComputer In ActiveCompList
Set objPCField = objXMLDoc.createElement("PC")
rootEl.appendChild(objPCField)
Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
  strComputer & "\root\default:StdRegProv")
oReg.GetBinaryValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,iValues
Dim arrDPID
arrDPID = Array()
For i = 52 to 66
ReDim Preserve arrDPID( UBound(arrDPID) + 1 )
arrDPID( UBound(arrDPID) ) = iValues(i)
Next
' <--------------- Create an array to hold the valid characters for a microsoft Product Key -------------------------->
Dim arrChars
arrChars = Array("B","C","D","F","G","H","J","K","M","P","Q","R","T","V","W","X","Y","2","3","4","6","7","8","9")
' <--------------- The clever bit !!! (Decrypt the base24 encoded binary data)-------------------------->
strProductKey = ""
For i = 24 To 0 Step -1
k = 0
For j = 14 To 0 Step -1
k = k * 256 Xor arrDPID(j)
arrDPID(j) = Int(k / 24)
k = k Mod 24
Next
strProductKey = arrChars(k) & strProductKey
If i Mod 5 = 0 And i <> 0 Then strProductKey = "-" & strProductKey
Next
strFinalKey = strProductKey
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery("select * from Win32_OperatingSystem")
For Each objOperatingsystem in colOperatingSystems
strOS   = objOperatingsystem.Caption
strBuild   = objOperatingsystem.BuildNumber
strSerial   = objOperatingsystem.SerialNumber
strRegistered  = objOperatingsystem.RegisteredUser
Next
Set objNewNode = objXMLDoc.createElement("Name")
Set objNewText = objXMLDoc.createTextNode(strComputer)
objPCField.appendChild(objNewNode)
objNewNode.appendChild(objNewText)
Set objNewNode = objXMLDoc.createElement("OS")
Set objNewText = objXMLDoc.createTextNode(strOS)
objPCField.appendChild(objNewNode)
objNewNode.appendChild(objNewText)
Set objNewNode = objXMLDoc.createElement("Build")
Set objNewText = objXMLDoc.createTextNode(strBuild)
objPCField.appendChild(objNewNode)
objNewNode.appendChild(objNewText)
Set objNewNode = objXMLDoc.createElement("PID")
Set objNewText = objXMLDoc.createTextNode(strSerial)
objPCField.appendChild(objNewNode)
objNewNode.appendChild(objNewText)
Set objNewNode = objXMLDoc.createElement("RegisteredTo")
Set objNewText = objXMLDoc.createTextNode(strRegistered)
objPCField.appendChild(objNewNode)
objNewNode.appendChild(objNewText)
Set objNewNode = objXMLDoc.createElement("Key")
Set objNewText = objXMLDoc.createTextNode(strFinalKey)
objPCField.appendChild(objNewNode)
objNewNode.appendChild(objNewText)
Next
'Add an XML processing instruction and insert it before the root element
Set p=objXMLDoc.createProcessingInstruction("xml","version='1.0'")
xmlDoc.insertBefore p,objXMLDoc.childNodes(0)
objXMLDoc.Save("report.xml")
IE.Quit
set IE = Nothing
MsgBox("Finished")
' <----------------------- Function to check if computer is switched on and responding to Ping ---------------------->
Function Reachable(strComputer)
' On Error Resume Next
Dim wmiQuery, objWMIService, objPing, objStatus
wmiQuery = "Select * From Win32_PingStatus Where Address = '" & strComputer & "'"
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set objPing = objWMIService.ExecQuery(wmiQuery)
For Each objStatus in objPing
If IsNull(objStatus.StatusCode) Or objStatus.Statuscode<>0 Then
Reachable = False 'if computer is unreacable, return false
Else
Reachable = True 'if computer is reachable, return true
End If
Next
End Function


travisb
  • Total Posts : 1
  • Scores: 0
  • Reward points : 0
  • Joined: 5/3/2007
RE: Retrieve Windows Product Key - Friday, February 13, 2009 4:01 AM
0
Is it possible to add a list of computer names or IP addresses that you want scanned? This way you do not have to scan the entire domain. I'm new to VBS and not sure where I would start. Can anyone help with this?

dm_4ever
  • Total Posts : 3687
  • Scores: 82
  • Reward points : 0
  • Joined: 6/29/2006
  • Location: Orange County, California
RE: Retrieve Windows Product Key - Wednesday, February 18, 2009 4:13 PM
0
Simply assign computers to the array ActiveCompList and use the existing code.
dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

chrisupman
  • Total Posts : 1
  • Scores: 0
  • Reward points : 0
  • Joined: 3/21/2010
RE: Retrieve Windows Product Key - Sunday, March 21, 2010 11:52 PM
0
Has anyone had any success in getting this script to work in a windows x64 environment? 
 
I have been trying to get the HTA version to work in windows 7 x64 by spawning the old script host
 Set oSH = CreateObject("WScript.Shell")
Set oFS = CreateObject("Scripting.FileSystemObject")
 
strOldWSH = oSH.ExpandEnvironmentStrings("%SYSTEMROOT%\SysWOW64\wscript.exe")
If oFS.FileExists(strOldWSH) Then
    If Not UCase(WScript.FullName) = UCase(strOldWSH) Then
        oSH.Run """" & strOldWSH & """ """ & WScript.ScriptFullName & """", 1, False
        WScript.Echo "Running on 64-bit WSH."
       
       
       
    End If
End If
This information was posted on the MS scripting guys site.
       
I have had no luck in getting any results.
 
What tecnniques

ryanxcom
  • Total Posts : 1
  • Scores: 0
  • Reward points : 0
  • Joined: 4/24/2012
Re: RE: Retrieve Windows Product Key - Tuesday, April 24, 2012 6:50 PM
0
Parabellum,
 
I have your previous code (last update Dec-28-2009).
I have done major tweak to it to meet my needs. The only issue is that it does not capture the serials for Office 2010. And i really do not know where to start as your current scripts does not match the previous script. In addition to that I have made the script to output to HTML then it updates the database (phpmyadmin) via WAMP. No problem in the updates and outputs.. 
 
Could you kindly make the changes to capture MS office 2010 on my behalf? I have the codes.
 
 '// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'//
'// NAME:        osinfo.vbs
'//
'// Original:    http://www.cluberti.com/blog
'// Last Update: 28th December 2009
'//
'// Comment:     VBS example file for use as an OS info gathering template.
'//
'// NOTE:        Provided as-is - usage of this source assumes that you are at the
'//              very least familiar with the vbscript language being used and
'//              the tools used to create and debug this file.
'//
'//              In other words, if you break it, you get to keep the pieces.
'//
'//              Also, if you want to use this on W2K, prepare to hack, as this
'//              was really designed with XP+ systems in mind.
'//
'// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

'***** HACKED*****
'//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ progress bar function ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Function ProgressMsg( strMessage, strWindowTitle )
' Written by Denis St-Pierre
' Displays a progress message box that the originating script can kill in both 2k and XP
' If StrMessage is blank, take down previous progress message box
' Using 4096 in Msgbox below makes the progress message float on top of things
' CAVEAT: You must have   Dim ObjProgressMsg   at the top of your script for this to work as described
    Set wshShell = WScript.CreateObject( "WScript.Shell" )
    strTEMP = wshShell.ExpandEnvironmentStrings( "%TEMP%" )
    If strMessage = "" Then
        ' Disable Error Checking in case objProgressMsg doesn't exists yet
        On Error Resume Next
        ' Kill ProgressMsg
        objProgressMsg.Terminate( )
        ' Re-enable Error Checking
        On Error Goto 0
        Exit Function
    End If
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    strTempVBS = strTEMP + "\" & "Message.vbs"     'Control File for reboot

    ' Create Message.vbs, True=overwrite
    Set objTempMessage = objFSO.CreateTextFile( strTempVBS, True )
    objTempMessage.WriteLine( "MsgBox""" & strMessage & """, 4096, """ & strWindowTitle & """" )
    objTempMessage.Close

    ' Disable Error Checking in case objProgressMsg doesn't exists yet
    On Error Resume Next
    ' Kills the Previous ProgressMsg
    objProgressMsg.Terminate( )
    ' Re-enable Error Checking
    On Error Goto 0

    ' Trigger objProgressMsg and keep an object on it
    Set objProgressMsg = WshShell.Exec( "%windir%\system32\wscript.exe " & strTempVBS )

    Set wshShell = Nothing
    Set objFSO   = Nothing
End Function
'//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~end of progress bar function ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


'//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'//
'// This script will require elevated privileges if run from a non-admin account, so
'// calling the ElevateThisScript() Sub should get the script a full admin token. This is
'// currently disabled, but if you need non-admin users to run this script, enable the
'// call to this subroutine to pop-up a dialog box (they'll of course need administrative
'// credentials to put in the challenge dialog before the script will execute with an
'// administrative token):

' ElevateThisScript()


'//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'//
'// Set variables and wMI connections for scripting against:
CONST HKEY_LOCAL_MACHINE = &H80000002
CONST SEARCH_KEY = "DigitalProductID"
Dim arrSubKeys(4,1)
Dim foundKeys
dim MSType1, MSType, strWindowTitle
Dim objProgressMsg


Dim iValues, arrDPID
foundKeys = Array()
iValues = Array()
arrSubKeys(0,0) = "Windows PID Key:       "
arrSubKeys(0,1) = "SOFTWARE\Microsoft\Windows NT\CurrentVersion"
arrSubKeys(2,0) = "Office XP PID Key:     "
arrSubKeys(2,1) = "SOFTWARE\Microsoft\Office\10.0\Registration"
arrSubKeys(1,0) = "Office 2003 PID Key:   "
arrSubKeys(1,1) = "SOFTWARE\Microsoft\Office\11.0\Registration"
arrSubKeys(3,0) = "Office 2007 PID Key:   "
arrSubKeys(3,1) = "SOFTWARE\Microsoft\Office\12.0\Registration"
arrSubKeys(4,0) = "Office 2010 PID Key:   "
arrSubKeys(4,1) = "SOFTWARE\Microsoft\Office\14.0\Registration"

strComputer = "."
Arch = ""
Sku = ""
MSType1=""
MSType=""
strProgress=""


Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
Set objSWbemDateTime = CreateObject("WbemScripting.SWbemDateTime")

Set colOSItems = objWMIService.ExecQuery( _
    "SELECT * FROM Win32_OperatingSystem",,48)

Set colProcItems = objWMIService.ExecQuery( _
    "SELECT * FROM Win32_Processor",,48)

Set colCompSysItems = objWMIService.ExecQuery( _
    "SELECT * FROM Win32_ComputerSystem",,48) 

Set colTZItems = objWMIService.ExecQuery( _
    "SELECT * FROM Win32_TimeZone",,48) 

Set colCompSysProdItems = objWMIService.ExecQuery( _
    "SELECT * FROM Win32_ComputerSystemProduct",,48)

Set colBIOSItems = objWMIService.ExecQuery( _
    "SELECT * FROM Win32_BIOS",,48)

Set colDiskItems = objWMIService.ExecQuery( _
    "SELECT * FROM Win32_LogicalDisk",,48) 

Set colNetAdapConfigItems = objWMIService.ExecQuery( _
    "SELECT * FROM Win32_NetworkAdapterConfiguration",,48) 

Set colVideoItems = objWMIService.ExecQuery( _
    "SELECT * FROM Win32_VideoController",,48) 

Set colSoundItems = objWMIService.ExecQuery( _
    "SELECT * FROM Win32_SoundDevice",,48) 


'//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'//
'// Get OS SKU from Win32_OperatingSystem class:

    For Each objOSItem in colOSItems
    If objOSItem.BuildNumber => 6000 Then
        Arch = objOSItem.OSArchitecture

        Select Case objOSItem.OperatingSystemSKU
            Case 0 Sku = "Unknown Windows version"
            Case 1 Sku = "Ultimate Edition"
            Case 2 Sku = "Home Basic Edition"
            Case 3 Sku = "Home Premium Edition"
            Case 4 Sku = "Enterprise Edition"
            Case 5 Sku = "Home Basic N Edition"
            Case 6 Sku = "Business Edition"
            Case 7 Sku = "Standard Server Edition"
            Case 8 Sku = "Datacenter Server Edition"
            Case 9 Sku = "Small Business Server Edition"
            Case 10 Sku = "Enterprise Server Edition"
            Case 11 Sku = "Starter Edition"
            Case 12 Sku = "Datacenter Server Core Edition"
            Case 13 Sku = "Standard Server Core Edition"
            Case 14 Sku = "Enterprise Server Core Edition"
            Case 15 Sku = "Enterprise Server Edition for Itanium-Based Systems"
            Case 16 Sku = "Business N Edition"
            Case 17 Sku = "Web Server Edition"
            Case 18 Sku = "Cluster Server Edition"
            Case 19 Sku = "Home Server Edition"
            Case 20 Sku = "Storage Express Server Edition"
            Case 21 Sku = "Storage Standard Server Edition"
            Case 22 Sku = "Storage Workgroup Server Edition"
            Case 23 Sku = "Storage Enterprise Server Edition"
            Case 24 Sku = "Server For Small Business Edition"
            Case 25 Sku = "Small Business Server Premium Edition"
            Case Else
            Sku = "Could Not Determine Operating System SKU"
        End Select
    End If


'//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'//
'// Get current OS locale setting from Win32_OperatingSystem class:

        Select Case objOSItem.Locale
            Case 0436 Locale = "Afrikaans (South Africa)"
            Case 041c Locale = "Albanian (Albania)"
            ' Case 045e Locale = "Amharic (Ethiopia)"
            Case 0401 Locale = "Arabic (Saudi Arabia)"
            Case 1401 Locale = "Arabic (Algeria)"
            Case 3c01 Locale = "Arabic (Bahrain)"
            Case 0c01 Locale = "Arabic (Egypt)"
            Case 0801 Locale = "Arabic (Iraq)"
            Case 2c01 Locale = "Arabic (Jordan)"
            Case 3401 Locale = "Arabic (Kuwait)"
            Case 3001 Locale = "Arabic (Lebanon)"
            Case 1001 Locale = "Arabic (Libya)"
            Case 1801 Locale = "Arabic (Morocco)"
            Case 2001 Locale = "Arabic (Oman)"
            Case 4001 Locale = "Arabic (Qatar)"
            Case 2801 Locale = "Arabic (Syria)"
            Case 1c01 Locale = "Arabic (Tunisia)"
            Case 3801 Locale = "Arabic (U.A.E.)"
            Case 2401 Locale = "Arabic (Yemen)"
            Case 042b Locale = "Armenian (Armenia)"
            Case 044d Locale = "Assamese"
            Case 082c Locale = "Azeri (Cyrillic)"
            Case 042c Locale = "Azeri (Latin)"
            Case 042d Locale = "Basque"
            Case 0423 Locale = "Belarusian"
            Case 0445 Locale = "Bengali (India)"
            Case 0845 Locale = "Bengali (Bangladesh)"
            Case 141A Locale = "Bosnian (Bosnia/Herzegovina)"
            Case 0402 Locale = "Bulgarian"
            Case 0455 Locale = "Burmese"
            Case 0403 Locale = "Catalan"
            Case 045c Locale = "Cherokee (United States)"
            Case 0804 Locale = "Chinese (PRC)"
            Case 1004 Locale = "Chinese (Singapore)"
            Case 0404 Locale = "Chinese (Taiwan)"
            Case 0c04 Locale = "Chinese (Hong Kong SAR)"
            Case 1404 Locale = "Chinese (Macao SAR)"
            Case 041a Locale = "Croatian"
            Case 101a Locale = "Croatian (Bosnia/Herzegovina)"
            Case 0405 Locale = "Czech"
            Case 0406 Locale = "Danish"
            Case 0465 Locale = "Divehi"
            Case 0413 Locale = "Dutch (Netherlands)"
            Case 0813 Locale = "Dutch (Belgium)"
            Case 0466 Locale = "Edo"
            Case 0409 Locale = "English (United States)"
            Case 0809 Locale = "English (United Kingdom)"
            Case 0c09 Locale = "English (Australia)"
            Case 2809 Locale = "English (Belize)"
            Case 1009 Locale = "English (Canada)"
            Case 2409 Locale = "English (Caribbean)"
            Case 3c09 Locale = "English (Hong Kong SAR)"
            Case 4009 Locale = "English (India)"
            Case 3809 Locale = "English (Indonesia)"
            Case 1809 Locale = "English (Ireland)"
            Case 2009 Locale = "English (Jamaica)"
            Case 4409 Locale = "English (Malaysia)"
            Case 1409 Locale = "English (New Zealand)"
            Case 3409 Locale = "English (Philippines)"
            Case 4809 Locale = "English (Singapore)"
            Case 1c09 Locale = "English (South Africa)"
            Case 2c09 Locale = "English (Trinidad)"
            Case 3009 Locale = "English (Zimbabwe)"
            Case 0425 Locale = "Estonian"
            Case 0438 Locale = "Faroese"
            Case 0429 Locale = "Farsi"
            Case 0464 Locale = "Filipino"
            Case 040b Locale = "Finnish"
            Case 040c Locale = "French (France)"
            Case 080c Locale = "French (Belgium)"
            Case 2c0c Locale = "French (Cameroon)"
            Case 0c0c Locale = "French (Canada)"
            Case 240c Locale = "French (DRC)"
            Case 300c Locale = "French (Cote d'Ivoire)"
            Case 3c0c Locale = "French (Haiti)"
            Case 140c Locale = "French (Luxembourg)"
            Case 340c Locale = "French (Mali)"
            Case 180c Locale = "French (Monaco)"
            Case 380c Locale = "French (Morocco)"
            Case e40c Locale = "French (North Africa)"
            Case 200c Locale = "French (Reunion)"
            Case 280c Locale = "French (Senegal)"
            Case 100c Locale = "French (Switzerland)"
            Case 1c0c Locale = "French (West Indies)"
            Case 0462 Locale = "Frisian (Netherlands)"
            Case 0467 Locale = "Fulfulde (Nigeria)"
            Case 042f Locale = "FYRO Macedonian"
            Case 083c Locale = "Gaelic (Ireland)"
            Case 043c Locale = "Gaelic (Scotland)"
            Case 0456 Locale = "Galician"
            Case 0437 Locale = "Georgian"
            Case 0407 Locale = "German (Germany)"
            Case 0c07 Locale = "German (Austria)"
            Case 1407 Locale = "German (Liechtenstein)"
            Case 1007 Locale = "German (Luxembourg)"
            Case 0807 Locale = "German (Switzerland)"
            Case 0408 Locale = "Greek"
            Case 0474 Locale = "Guarani (Paraguay)"
            Case 0447 Locale = "Gujarati"
            Case 0468 Locale = "Hausa (Nigeria)"
            Case 0475 Locale = "Hawaiian (United States)"
            Case 040d Locale = "Hebrew"
            Case 0439 Locale = "Hindi"
            ' Case 040e Locale = "Hungarian"
            Case 0469 Locale = "Ibibio (Nigeria)"
            Case 040f Locale = "Icelandic"
            Case 0470 Locale = "Igbo (Nigeria)"
            Case 0421 Locale = "Indonesian"
            Case 045d Locale = "Inuktitut"
            Case 0410 Locale = "Italian (Italy)"
            Case 0810 Locale = "Italian (Switzerland)"
            Case 0411 Locale = "Japanese"
            Case 044b Locale = "Kannada"
            Case 0471 Locale = "Kanuri (Nigeria)"
            Case 0860 Locale = "Kashmiri"
            Case 0460 Locale = "Kashmiri (Arabic)"
            Case 043f Locale = "Kazakh"
            Case 0453 Locale = "Khmer"
            Case 0457 Locale = "Konkani"
            Case 0412 Locale = "Korean"
            Case 0440 Locale = "Kyrgyz (Cyrillic)"
            Case 0454 Locale = "Lao"
            Case 0476 Locale = "Latin"
            Case 0426 Locale = "Latvian"
            Case 0427 Locale = "Lithuanian"
            ' Case 043e Locale = "Malay (Malaysia)"
            ' Case 083e Locale = "Malay (Brunei Darussalam)"
            Case 044c Locale = "Malayalam"
            Case 043a Locale = "Maltese"
            Case 0458 Locale = "Manipuri"
            Case 0481 Locale = "Maori (New Zealand)"
            ' Case 044e Locale = "Marathi"
            Case 0450 Locale = "Mongolian (Cyrillic)"
            Case 0850 Locale = "Mongolian (Mongolian)"
            Case 0461 Locale = "Nepali"
            Case 0861 Locale = "Nepali (India)"
            Case 0414 Locale = "Norwegian (Bokmеl)"
            Case 0814 Locale = "Norwegian (Nynorsk)"
            Case 0448 Locale = "Oriya"
            Case 0472 Locale = "Oromo"
            Case 0479 Locale = "Papiamentu"
            Case 0463 Locale = "Pashto"
            Case 0415 Locale = "Polish"
            Case 0416 Locale = "Portuguese (Brazil)"
            Case 0816 Locale = "Portuguese (Portugal)"
            Case 0446 Locale = "Punjabi"
            Case 0846 Locale = "Punjabi (Pakistan)"
            Case 046B Locale = "Quecha (Bolivia)"
            Case 086B Locale = "Quecha (Ecuador)"
            Case 0C6B Locale = "Quecha (Peru)"
            Case 0417 Locale = "Rhaeto-Romanic"
            Case 0418 Locale = "Romanian"
            Case 0818 Locale = "Romanian (Moldava)"
            Case 0419 Locale = "Russian"
            Case 0819 Locale = "Russian (Moldava)"
            Case 043b Locale = "Sami (Lappish)"
            Case 044f Locale = "Sanskrit"
            Case 046c Locale = "Sepedi"
            Case 0c1a Locale = "Serbian (Cyrillic)"
            Case 081a Locale = "Serbian (Latin)"
            Case 0459 Locale = "Sindhi (India)"
            Case 0859 Locale = "Sindhi (Pakistan)"
            Case 045b Locale = "Sinhalese (Sri Lanka)"
            Case 041b Locale = "Slovak"
            Case 0424 Locale = "Slovenian"
            Case 0477 Locale = "Somali"
            ' Case 042e Locale = "Sorbian"
            Case 0c0a Locale = "Spanish (Spain - Modern Sort)"
            Case 040a Locale = "Spanish (Spain - Traditional Sort)"
            Case 2c0a Locale = "Spanish (Argentina)"
            Case 400a Locale = "Spanish (Bolivia)"
            Case 340a Locale = "Spanish (Chile)"
            Case 240a Locale = "Spanish (Colombia)"
            Case 140a Locale = "Spanish (Costa Rica)"
            Case 1c0a Locale = "Spanish (Dominican Republic)"
            Case 300a Locale = "Spanish (Ecuador)"
            Case 440a Locale = "Spanish (El Salvador)"
            Case 100a Locale = "Spanish (Guatemala)"
            Case 480a Locale = "Spanish (Honduras)"
            Case 580a Locale = "Spanish (Latin America)"
            Case 080a Locale = "Spanish (Mexico)"
            Case 4c0a Locale = "Spanish (Nicaragua)"
            Case 180a Locale = "Spanish (Panama)"
            Case 3c0a Locale = "Spanish (Paraguay)"
            Case 280a Locale = "Spanish (Peru)"
            Case 500a Locale = "Spanish (Puerto Rico)"
            Case 540a Locale = "Spanish (United States)"
            Case 380a Locale = "Spanish (Uruguay)"
            Case 200a Locale = "Spanish (Venezuela)"
            Case 0430 Locale = "Sutu"
            Case 0441 Locale = "Swahili"
            Case 041d Locale = "Swedish"
            Case 081d Locale = "Swedish (Finland)"
            Case 045a Locale = "Syriac"
            Case 0428 Locale = "Tajik"
            Case 045f Locale = "Tamazight (Arabic)"
            Case 085f Locale = "Tamazight (Latin)"
            Case 0449 Locale = "Tamil"
            Case 0444 Locale = "Tatar"
            Case 044a Locale = "Telugu"
            ' Case 041e Locale = "Thai"
            Case 0851 Locale = "Tibetan (Bhutan)"
            Case 0451 Locale = "Tibetan (PRC)"
            Case 0873 Locale = "Tigrigna (Eritrea)"
            Case 0473 Locale = "Tigrigna (Ethiopia)"
            Case 0431 Locale = "Tsonga"
            Case 0432 Locale = "Tswana"
            Case 041f Locale = "Turkish"
            Case 0442 Locale = "Turkmen"
            Case 0480 Locale = "Uighur (China)"
            Case 0422 Locale = "Ukrainian"
            Case 0420 Locale = "Urdu"
            Case 0820 Locale = "Urdu (India)"
            Case 0843 Locale = "Uzbek (Cyrillic)"
            Case 0443 Locale = "Uzbek (Latin)"
            Case 0433 Locale = "Venda"
            Case 042a Locale = "Vietnamese"
            Case 0452 Locale = "Welsh"
            Case 0434 Locale = "Xhosa"
            Case 0478 Locale = "Yi"
            Case 043d Locale = "Yiddish"
            Case 046a Locale = "Yoruba"
            Case 0435 Locale = "Zulu"
            Case 04ff Locale = "HID (Human Interface Device)"
            Case Else
            Locale = "Could Not Determine OS Locale"
        End Select

strWindowTitle = "PC Audit - by Ryan"
ProgressMsg "Initializing, Please wait ...", strWindowTitle
'//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'//
'// Set variables gathered from Win32_OperatingSystem class:

        Caption = objOSItem.Caption
        CSDVersion = objOSItem.CSDVersion
        CSName = objOSItem.CSName
        Version = objOSItem.Version
        BuildType = objOSItem.BuildType
        BuildNumber = objOSItem.BuildNumber
        SerialNumber = objOSItem.SerialNumber

        objSWbemDateTime.Value = objOSItem.InstallDate
        InstallDate = objSWbemDateTime.GetVarDate(True)

        objSWbemDateTime.Value = objOSItem.LastBootUpTime
        LastBootUpTime = objSWbemDateTime.GetVarDate(True)

        Status = objOSItem.Status
    Next


'//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'//
'// Set variables gathered from Win32_ComputerSystem class:

    For Each objCompSysItem in colCompSysItems
        CurrentTimeZone = objCompSysItem.CurrentTimeZone
        DaylightInEffect = objCompSysItem.DaylightInEffect
        TotalMemory = FormatNumber(objCompSysItem.TotalPhysicalMemory/1024^3, 2)
    Next


'//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'//
'// Set variables gathered from Win32_TimeZone class:

    For Each objTZItem in colTZItems
        TZName = objTZItem.StandardName
    Next


'//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'//
'// Set variables gathered from Win32_ComputerSystemProduct class:

    For Each objCompSysProdItem in colCompSysProdItems
        CompSysName = objCompSysProdItem.Name
        IdentifyingNumber = objCompSysProdItem.IdentifyingNumber
        UUID = objCompSysProdItem.UUID
    Next


'//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'//
'// Set variables gathered from Win32_BIOS class:

    For Each objBIOSItem in colBIOSItems
        SMBIOSVersion = objBIOSItem.SMBIOSBIOSVersion
    Next


'//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
WScript.Sleep 3000


'// Get the product keys (function at the end of script):

ProgressMsg "Looking for License(s) Numbers...", strWindowTitle

GetKeys() ' ################################################# remove the comment tag at the front - ryan
WScript.Sleep 3000


 '//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'//

'// Set and echo variables gathered from Win32_Processor class:

ProgressMsg "Gathering CPU details...", strWindowTitle

       
    For Each objProcItem in colProcItems
        Select Case objProcItem.Architecture
            Case 0 CPUArch = "x86"
            Case 1 CPUArch = "MIPS"
            Case 2 CPUArch = "Alpha"
            Case 3 CPUArch = "PowerPC"
            Case 6 CPUArch = "Itanium"
            Case 9 CPUArch = "x64"
            Case Else
            CPUArch = "Could Not Determine CPU Architecture"
        End Select
    CPUmsg = objProcItem.Name & " (" & CPUArch & ")" '################## DO NOT Delete this line - ryan
    Next
    RAMmsg = TotalMemory '################## DO NOT Delete this line - ryan
WScript.Sleep 3000


'//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'//
'//
'// Set variables gathered from Win32_LogicalDisk class:
logdisk=""
ProgressMsg "Gathering HArd Disk details...", strWindowTitle

DriveCount=0
    For Each objDiskItem in colDiskItems
        If objDiskItem.DriveType = 3 Then
            'logdisk = logdisk & "<tr><td>Drive :</td><td><input type=""text""  name=""Drive"" readonly=""readonly"" value=""" & objDiskItem.Caption & """></td></tr>" & vbCrLf 
            'logdisk = logdisk & "<tr><td>File System:</td><td><input type=""text""  name=""           " & objDiskItem.FileSystem & vbCrLf
            logdisk = logdisk & "<tr><td>HDD Size:</td><td><input type=""text""  name=""HDD_Size"" readonly=""readonly"" value=""" & FormatNumber(objDiskItem.Size/1024^3, 2) & " GB"" ></td></tr>" & vbCrLf
            'logdisk = logdisk & "<tr><td>Free Space:            " & FormatNumber(objDiskItem.FreeSpace/1024^3, 2) & " GB" & vbCrLf
                     DriveCount = DriveCount + 1     
              if DriveCount > 0 Then Exit For
       End If
    Next
WScript.Sleep 3000

'MsgBox logdisk 



'//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

'// Set variables gathered from Win32_NetworkAdapterConfiguration class:

ProgressMsg "Gathering Network details...", strWindowTitle

ComputerDetail=""
netmsg = "<tr><td colspan=""2"" align=""center"">Network Details</td></tr>" & vbCrLf
CountAdaptor=0

    For Each objNetAdapConfigItem in colNetAdapConfigItems
        If isNull(objNetAdapConfigItem.IPAddress) Then
            '// Skip adapter, not currently used
        Else
            netmsg = netmsg & "<tr><td>Network Adapter:</td><td><input type=""text""  name=""Net_Adaptor"" readonly=""readonly"" value=""" & objNetAdapConfigItem.Description & """></td></tr>" & vbCrLf
            netmsg = netmsg & "<tr><td>MAC Address:</td><td><input type=""text""  name=""MAC"" readonly=""readonly"" value=""" & objNetAdapConfigItem.MACAddress & """></td></tr>" & vbCrLf
            'netmsg = netmsg & "     DHCP Enabled:          " & objNetAdapConfigItem.DHCPEnabled & vbCrLf
            netmsg = netmsg & "<tr><td>IP Address:</td><td><input type=""text""  name=""IP_Add"" readonly=""readonly"" value=""" & Join(objNetAdapConfigItem.IPAddress, ",") & """></td></tr>" & vbCrLf
            'netmsg = netmsg & "     Subnet Mask:           " & Join(objNetAdapConfigItem.IPSubnet, ",") & vbCrLf
            'netmsg = netmsg & "     Default Gateway:       " & Join(objNetAdapConfigItem.DefaultIPGateway, ",") & vbCrLf
            'If objNetAdapConfigItem.DHCPEnabled = True Then

            '    objSWbemDateTime.Value = objNetAdapConfigItem.DHCPLeaseObtained
            '    DHCPLeaseObtained = objSWbemDateTime.GetVarDate(True)
            '    netmsg = netmsg & "     Lease Obtained:        " & DHCPLeaseObtained  & vbCrLf

            '    objSWbemDateTime.Value = objNetAdapConfigItem.DHCPLeaseExpires
            '    DHCPLeaseExpires = objSWbemDateTime.GetVarDate(True)
            '    netmsg = netmsg & "     Lease Exipres:         " & DHCPLeaseExpires  & vbCrLf & vbCrLf

            '    netmsg = netmsg & "     DHCP Servers:          " & objNetAdapConfigItem.DHCPServer & vbCrLf
            'End If
            'netmsg = netmsg & "     DNS Server:            " & Join(objNetAdapConfigItem.DNSServerSearchOrder, ",") & vbCrLf
            'If Not objNetAdapConfigItem.WINSPrimaryServer = "" Then
            '    netmsg = netmsg & "     WINS Primary Server:   " & objNetAdapConfigItem.WINSPrimaryServer & vbCrLf
            '    If Not objNetAdapConfigItem.WINSSecondaryServer = "" Then
            '        netmsg = netmsg & "     WINS Secondary Server: " & objNetAdapConfigItem.WINSPrimaryServer & vbCrLf
            '    End If
            '    netmsg = netmsg & "     Enable LMHosts Lookup: " & objNetAdapConfigItem.WINSEnableLMHostsLookup & vbCrLf
            'End If
            
        End If
       
    Next

    ComputerDetail = "<tr><td>Computer Model:</td><td><input type=""text""  name=""CPU_Model"" readonly=""readonly"" value=""" & CompSysName & """></td></tr>" & vbCrLf & _
    "<tr><td>CPU Serial Number:</td><td><input type=""text""  name=""CPU_Serial"" readonly=""readonly"" value=""" & IdentifyingNumber & """></td></tr>" & vbCrLf
    '"     BIOS Version:          " & SMBIOSVersion & vbCrLf & _
    '"     UUID:                  " & UUID & vbCrLf 
       'MsgBox ComputerDetail

WScript.Sleep 3000


'//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'//
'// This pause call is disabled, but you may wish to enable it if running this script
'// with the ElevateThisScript() subroutine call enabled above:

' PressEnter()


'//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



'//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'//
'// Functions: GetKeys() and decodeKey(iValues, strProduct)
'//
'// Credit where credit is due - I found and modified script posted by user "Parabellum"
'// found on http://www.visualbasicscript.com/m42793.aspx, hacked it up a bit, and used
'// it here to post keys:

Public Function GetKeys()
    For x = LBound(arrSubKeys, 1) To UBound(arrSubKeys, 1)
    objReg.GetBinaryValue HKEY_LOCAL_MACHINE, arrSubKeys(x,1), SEARCH_KEY, arrDPIDBytes

        If Not IsNull(arrDPIDBytes) Then
            Call decodeKey(arrDPIDBytes, arrSubKeys(x,0))
               
        Else
            objReg.EnumKey HKEY_LOCAL_MACHINE, arrSubKeys(x,1), arrGUIDKeys

            If Not IsNull(arrGUIDKeys) Then
                For Each GUIDKey In arrGUIDKeys
                    objReg.GetBinaryValue HKEY_LOCAL_MACHINE, arrSubKeys(x,1) & "\" & GUIDKey, SEARCH_KEY, arrDPIDBytes
                   '***********HACKED (don't remember why but it works)********** 
                    If Not IsNull(arrDPIDBytes) Then
                        Call decodeKey1(arrDPIDBytes, arrSubKeys(x,0))
                    End If
                Next
            End If
        End If
    Next

End Function


    Public Function decodeKey(iValues, strProduct)
        Dim arrDPID
        arrDPID = Array()

            For i = 52 to 66
                ReDim Preserve arrDPID( UBound(arrDPID) + 1 )
                arrDPID( UBound(arrDPID) ) = iValues(i)
            Next

        Dim arrChars
        arrChars = Array("B","C","D","F","G","H","J","K","M","P","Q","R","T","V","W","X","Y","2","3","4","6","7","8","9")

            For i = 24 To 0 Step -1
                k = 0
        
                For j = 14 To 0 Step -1
                    k = k * 256 Xor arrDPID(j)
                    arrDPID(j) = Int(k / 24)
                    k = k Mod 24
                Next
        
                strProductKey = arrChars(k) & strProductKey
        
                If i Mod 5 = 0 And i <> 0 Then
                    strProductKey = "-" & strProductKey
                End If
            Next
    
        ReDim Preserve foundKeys( UBound(foundKeys) + 1 )
        foundKeys( UBound(foundKeys) ) = strProductKey
        strKey = UBound(foundKeys)
        'Wscript.Echo "   1  " & strProduct & "" & foundKeys(strKey)
       MSType1 = "<tr><td>OS License:</td><td><input type=""text""  name=""OS_License"" readonly=""readonly"" value=""" & foundKeys(strKey) & """></td></tr>"  &vbCrLf
       'Wscript.Echo MSType1
    End Function



'******* HACKED (copy of decodekey function)***********
    Public Function decodeKey1(iValues, strProduct) '######################### this is for Office KEY search
        Dim arrDPID
        arrDPID = Array()

            For i = 52 to 66
                ReDim Preserve arrDPID( UBound(arrDPID) + 1 )
                arrDPID( UBound(arrDPID) ) = iValues(i)
            Next

        Dim arrChars
        arrChars = Array("B","C","D","F","G","H","J","K","M","P","Q","R","T","V","W","X","Y","2","3","4","6","7","8","9")

            For i = 24 To 0 Step -1
                k = 0
        
                For j = 14 To 0 Step -1
                    k = k * 256 Xor arrDPID(j)
                    arrDPID(j) = Int(k / 24)
                    k = k Mod 24
                Next
        
                strProductKey = arrChars(k) & strProductKey
        
                If i Mod 5 = 0 And i <> 0 Then
                    strProductKey = "-" & strProductKey
                End If
            Next
    
        ReDim Preserve foundKeys( UBound(foundKeys) + 1 )
        foundKeys( UBound(foundKeys) ) = strProductKey
        strKey = UBound(foundKeys)
        'Wscript.Echo "   2  " & strProduct & "" & foundKeys(strKey)
       MSType = "<tr><td>Office License:</td><td><input type=""text""  name=""MS_License"" readonly=""readonly"" value=""" & foundKeys(strKey) & """></td></tr>"  &vbCrLf
       'Wscript.Echo MSType
    End Function




'//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'//
'// Subroutine: PressEnter()
'//
'// Adds a pause with a "Press the ENTER key to continue." message when called.
'//
'// Usage:  Call this Subroutine to get a pause that will clear when the user presses the
'// ENTER key (and ONLY the ENTER key) on their keyboard:

Sub PressEnter()
    Wscript.Echo ""
    strMessage = "Press the ENTER key to continue. "
    Wscript.StdOut.Write strMessage

    Do While Not WScript.StdIn.AtEndOfLine
        Input = WScript.StdIn.Read(1)
    Loop
End Sub



'//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'//
'// Subroutine: ElevateThisScript()
'//
'// Forces the currently running script to prompt for elevation if it detects that the
'// current user credentials do not have administrative privileges.
'//
'// If run on Windows XP / Server 2003 this script will cause the RunAs dialog to appear
'// if the user does not have administrative rights, giving the opportunity to run as an
'// administrator.
'//
'// If run on Windows Vista / Server 2008 this script will cause a UAC dialog to appear
'// if the user does not have administrative rights and UAC is enabled, giving the
'// opportunity for the script to run properly for a LUA user.
'//
'// This Sub Attempts to call the script with its original arguments.  Arguments that
'// contain a space will be wrapped in double quotes when the script calls itself again.
'//
'// Usage:  Add a call to this sub (ElevateThisScript) to the beginning of your script to
'// ensure that the script gets an administrative token.

Sub ElevateThisScript()

       Const HKEY_CLASSES_ROOT  = &H80000000
       Const HKEY_CURRENT_USER  = &H80000001
       Const HKEY_LOCAL_MACHINE = &H80000002
       Const HKEY_USERS         = &H80000003
       const KEY_QUERY_VALUE        = 1
       Const KEY_SET_VALUE          = 2

       Dim scriptEngine, engineFolder, argString, arg, Args, scriptCommand
       Dim objShellApp : Set objShellApp = CreateObject("Shell.Application")

       scriptEngine = Ucase(Mid(Wscript.FullName,InstrRev(Wscript.FullName,"\")+1))
       engineFolder = Left(Wscript.FullName,InstrRev(Wscript.FullName,"\"))
       argString = ""

       Set Args = Wscript.Arguments

       For each arg in Args                                   'loop though argument array as a collection to rebuild argument string
              If instr(arg," ") > 0 Then arg = """" & arg & """"     'if the argument contains a space wrap it in double quotes
              argString = argString & " " & Arg
       Next

       scriptCommand = engineFolder & scriptEngine

       Dim strComputer : strComputer = "."

       Dim objReg, bHasAccessRight
       Set objReg=GetObject("winmgmts:"_
              & "{impersonationLevel=impersonate}!\\" &_
              strComputer & "\root\default:StdRegProv")

       'Check for administrative registry access rights
       objReg.CheckAccess HKEY_LOCAL_MACHINE, "System\CurrentControlSet\Control\CrashControl", _
              KEY_SET_VALUE, bHasAccessRight

       If bHasAccessRight = True Then

              HasRequiredRegAccess = True
              Exit Sub

       Else

              HasRequiredRegAccess = False
              objShellApp.ShellExecute scriptCommand, " """ & Wscript.ScriptFullName & """" & argString, "", "runas"
              WScript.Quit
       End If
End Sub
 '*********** HACKED *************
ProgressMsg "Gathering Display/Monitor Information ...", strWindowTitle

Dim FSO, RegEx, WMI, WSH  
Dim B, bn, ch1, chs, Desc, EDID, i, mfdt, wd, x    
Set FSO = CreateObject("Scripting.FileSystemObject")    
Set WMI = GetObject("winmgmts:" & "\\.\root\cimv2")    
Set WSH = CreateObject("WScript.Shell")  
Monitr=""
  
For Each i in WMI.ExecQuery("SELECT * FROM Win32_DesktopMonitor")    
EDID = False : Desc = ""  

On Error Resume Next  
  
EDID = WSH.RegRead("HKLM\System\CurrentControlSet\Enum\" &_   
i.PNPDeviceID & "\Device Parameters\EDID")    
Desc = WSH.RegRead("HKLM\System\CurrentControlSet\Enum\" &_    
i.PNPDeviceID & "\DeviceDesc")    

On Error Goto 0    
If TypeName(EDID) = "Variant()" Then Exit For  
  
Next    
If Not TypeName(EDID) = "Variant()" Then MsgBox "PnP Match not found!" _    
, , "Quitting..." : WScript.Quit    
B = ""    
wd = EDID(8) * 256 + EDID(9)    
mfdt = MonthName(Month(DateAdd("ww", EDID(16), "1/1/" & 1990 + EDID(17))))    
For i = 0 to UBound(EDID)    
B = B & Chr(EDID(i))    
Next  
  
Do Until wd < 1    
bn = wd Mod 2 & bn    
wd = wd \ 2    
ch1 = 0  
  
If Len(bn) = 5 Then    
Do While Len(bn)    
ch1 = ch1 + (Mid(bn, 1, 1) * (2 ^ (Len(bn) - 1)))    
bn = mid(bn, 2)    
Loop    
End If  
  
If ch1 Then chs = Chr(ch1 + 64) & chs    
Loop    
Set RegEx = New RegExp    
For Each x in Split("ModelName:c,VendorName:e,SerialNumber:f", ",")    
RegEx.Pattern = "\x00{3}[\xf" & Split(x, ":")(1) & "]\x00(.*)\x0a"  
If RegEx.Test(B) Then Execute Split(x, ":")(0) &_   
" = RegEx.Execute(B)(0).SubMatches(0)"    
Next  
  
Monitr= "<tr><td>Monitor Model:</td><td><input type=""text""  name=""Monitor_Model"" readonly=""readonly"" value=""" & ModelName & """></td</tr>" & vbCrLf & "<tr><td>Monitor Serial:</td><td><input type=""text""  name=""Monitor_Serial"" readonly=""readonly"" value=""" & SerialNumber & """></td></tr>" & vbCrLf & vbCrLf  


'********* HAKCED**************
' PrinterWMI.vbs
' Sample WMI Printer VBScript to interrogate properties
' Author Guy Thomas http://computerperformance.co.uk/
' Version 2.3 - December 2010
' -----------------------------------------------' 
'Option Explicit
Dim objWMIService, objItem, colItems, strComputer, intPrinters
prt = "<select name=""Printer_List"" size=""4"" readonly=""readonly"" >" & vbCrLf 

strComputer ="."
intPrinters = 1
PrinterList=""
' --------------------------------------------
' Pure WMI Section
Set objWMIService = GetObject _
("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery _
("SELECT * FROM Win32_Printer")

Call Wait() ' Goto Sub Routine at the end


' On Error Resume Next
For Each objItem In colItems
prt = prt & "<option readonly=""readonly"" value=""" & objItem.name  & "/" & objItem.PortName & """>" & ObjItem.name & " Port: " & objItem.PortName & "</option>" & vbCrLf

Next
'MsgBox prt


sub Wait()
If strComputer = "." then
strComputer = "Local Host"
else strComputer = strComputer
end if

End Sub
WScript.Sleep 3000

'//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'// function to identify type of MS Office 

Function GetOfficeVersion(strComputer)
    Set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
    Set colItems = objWMI.ExecQuery( _
        "SELECT Version FROM Win32_Product WHERE Name Like 'Microsoft Office%'")
        
    If colItems.Count = 0 Then
        GetOfficeVersion = "0"
        Exit Function
    End If
    
    For Each objItem In colItems
       'office= "Office :" & objItem.Version & vbCrLf 
       GetOfficeVersion= objItem.Name & vbCrLf 
        'GetOfficeVersion = Left(objItem.Version,InStr(1,objItem.Version,".")-1)
        Exit Function
    Next
    
    Set objWMI = Nothing
    Set colItems = Nothing
    Set objWMI = Nothing

End Function

'// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'************ OUTPUT to HTML-**************

'//######## to display monitor 
'// "<tr><td>CPU Serial: </td><td><input type=""text"" name=""CPU_Serial""  readonly=""readonly"" value=""" & SerialNumber & """></td></tr>" & vbcrlf & _


'//
'// Start echoing output to the screen 
ProgressMsg "Audit Completed. Click Ok to start creating Audit Report ...", strWindowTitle

myHtml=""
myHtml="<HTML><Head><Title>PC Inventory</Title></Head>" & vbcrlf & _
"<Body>" & vbcrlf & "<Table border=""0"" align=""center""><TR><td colspan=""2"" align=""center"">System Details</td></tr>" & vbcrlf & _
"<Form name=""NewInventory"" action=""http://205.220.52.50/Inventory/pcaudit.php"" method=""POST"">" &vbCrLf & _
"<tr><td>Computer Name:</td><td><input type=""text"" name=""CompName""  readonly=""readonly"" value=""" & CSName & """></td></tr>" & vbcrlf & _ 
"<tr><td>Description:</td><td><Input type=""text"" name=""Description""></td></tr>" & vbCrLf & _ 
"<tr><td>User Name:</td><td><input type=""text"" name=""User"" ></td></tr>" & vbCrLf & _
"<tr><td>Department:</td><td><input type=""text"" name=""Department""></td></tr>" & vbcrlf & _
ComputerDetail & _
"<tr><td>Operating System:</td><td><Input type=""text"" name=""OS""  readonly=""readonly"" value=""" & Caption & Arch & """></td></tr>" & vbcrlf & _
MSType1 & vbCrLf & _
"<tr><td>Processor Type:</td><td><input type=""text"" name=""Processor_type""  readonly=""readonly"" value=""" & CPUmsg & """ ></td></tr>" & vbcrlf & _
"<tr><td>RAM:</td><td><input type=""text"" name=""RAM""  readonly=""readonly"" value=""" & RAMmsg & """></td></tr>" & vbCrLf & _ 
logdisk & _ 
netmsg & _
"<tr><td colspan=""2"" align=""Center"">Software</td></tr>" & vbCrLf & _
"<tr><td>Ms Office Type</td><td><input type=""text"" name=""MS_OfficeType""  readonly=""readonly"" value=""" & GetOfficeVersion(CSName) & """></td></tr>" & vbCrlf & _
MSType & vbcrlf & _ 
"<tr><td colspan=""2"" align=""center"">Monitor Details</td></tr>" & vbCrLf & Monitr & vbCrLf & _
"<tr><td colspan=""2"" align=""center"">Printers Connected</td></tr>" & vbCrLf & _
"<tr><td>" & prt & "</td></tr>" & vbCrLf & _
"<tr><td style=""text-align:right;"" colspan=""2""><input type=""Submit"" name=""Update_Inventory"" readonly=""readonly"" value=""Update""><input type=""button"" readonly=""readonly"" value=""Close"" onClick=""window.close();""></td></tr>" & vbcrlf & _ 
"<tr><td colspan=""2""><div style=""font-size:10px;font-weight:bold;color:#AFC7C7;"">designed by Ryan</div></td></tr>" & vbCrLf & _
"</table>" & vbcrlf & _
"</Body></html>"


'Open up the path to save the information into a text file
Dim Stuff, myFSO, WriteStuff, dateStamp
dateStamp = Date()

'Write information to Text File
Stuff = myHtml
strFolder = "C:\Pc Inventory"

SET objFSO = CREATEOBJECT("Scripting.FileSystemObject")

IF objFSO.FolderExists(strFolder) = FALSE THEN
       objFSO.CreateFolder strFolder
END IF

Set myFSO = CreateObject("Scripting.FileSystemObject")
Set WriteStuff = myFSO.CreateTextFile("c:\pc inventory\ryan-inventory.html", 8, True)
WriteStuff.WriteLine(Stuff)
WriteStuff.Close

SET WriteStuff = NOTHING
SET myFSO = NOTHING


msgbox "Audit Report completed. Click Ok to open Report"
WScript.Sleep 3000


Dim IE
Set IE = CreateObject("InternetExplorer.Application")

With IE
        .left=200
        .top=200
        .height=600
        .width=800
        .menubar=0
        .toolbar=1   
        .statusBar=0
        .navigate "c:\pc inventory\ryan-inventory.html" 
        .visible=1
End With

'wait a while until IE as finished to load
Do while IE.busy
loop

Set IE = Nothing

WScript.Quit(0)

 
 
 

Change Page: < 12 | Showing page 2 of 2, messages 41 to 46 of 46