Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Vbscript registry

Vbscript registry

Vbscript registry

I am using a script in Altiris to run an inventory and collect info for a custom data class. On most pcs, the script runs and gets the value and then sends to the notification server and database. On some machines, I get an error-...vbs(79,1) (null): Invalid type for data field. On these pcs, the subkey does not exist. I would like the script to either return the value that is expected or just write key not found.


'DESCRIPTION: Gather UEFI Secure Boot Status from client registry and send to Altiris


const HKEY_LOCAL_MACHINE = &H80000002

strComputer = "."

Set oReg=GetObject( "winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")

strKeyPath = "SYSTEM\CurrentControlSet\Control\SecureBoot\State"

strValueName1 = "UEFISecureBootEnabled"

oReg.GetDWordValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName1,Value


'Create instance of Altiris NSE component

dim nse

set nse = WScript.CreateObject ("Altiris.AeXNSEvent")

' Set the header data of the NSE

nse.To = "{1592B913-72F3-4C36-91D2-D4EDA21D2F96}"

nse.Priority = 1

'Create Inventory data block. Here assumption is that the data class with below guid is already configured on server

dim objDCInstance

'Modify this class guid to match the one generated when you create the custom data class

set objDCInstance = nse.AddDataClass ("{64f22255-aa87-44aa-b088-5c1e93bde22f}")

dim objDataClass

set objDataClass = nse.AddDataBlock (objDCInstance)

'Add a new row

dim objDataRow

set objDataRow = objDataClass.AddRow

'Set columns

objDataRow.SetField 0, Value

'Wscript.Echo UEFISecureBootEnabled


RE: Vbscript registry

Here's how I resolve issues like yours:

On Error Resume Next
    [enter code here to get your subkey]
    If Err.Number <> 0 Then ShowError("Key not found")
On Error goto 0


Sub ShowError(strMessage)
    MsgBox strMessage & vbNewline & "Error number: " & Err.Number & vbNewline & "Source: " & Err.Source & vbNewline & "Description: " & Err.Description
End Sub 

This will allow you to continue without seeing the error message.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close