Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to check a reg key for a date stamp?

Status
Not open for further replies.

dmp92

Technical User
Feb 19, 2008
2
CA
This is a section of code I have been trying to work on. I need this to check for a paticular reg key. If there is no reg key or if the date stamp on the reg key is greater then the date stamp on the file then I need the script to continue other wise end script.

Option Explicit
'Dim objWMIService, objItem, colItems
Dim strComputer, strMbox, ArrDriveType, WMI, coldisks, disk, strtype, strID, strSys, UsbKey, file, USBFound
Dim objFSO:Set objFSO=CreateObject("Scripting.FileSystemObject")
Dim objFolderA: Set objFolderA=objFSO.GetFolder("\\bluewater\departments$\Information Technology\test\")


'****************** check to see if the files are more current ************************************************

' For Each file in objFolderA.Files
' Check for reg key "HKEY_LOCAL_MACHINE\SOFTWARE\EMERGENCY PLANNING" for date stamp
' if no reg key found on computer then continue with script
' if reg key is more current then file then
' WScript.Quit
 
This is what I have but it is not writing to the registry.

On Error Resume Next
const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\"&_
strComputer & "\root\default:StdRegProv")

KeyPath = "Software\Emergency Planning\File"
Return = objReg.CreateKey(HKEY_LOCAL_MACHINE, KeyPath)

If (Return = 0) And (Err.Number = 0) Then

Wscript.Echo "HKEY_LOCAL_MACHINE\Software\Emergency Planning\File created"
Else
Wscript.Echo "CreateKey failed. Error = " & Err.Number
End If


Any Ideas?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top