Option Explicit rem On Error Resume Next Dim oQuery Dim objConnection Dim objCommand Dim objRecordSet
oQuery = "<LDAP://dc=tcc,dc=local>;" & _ "(objectCategory=computer);" & _ "distinguishedName,name;subtree" Set objConnection = CreateObject("ADODB.Connection") Set objCommand = CreateObject("ADODB.Command") objConnection.Open "Provider=ADsDSOObject;" objCommand.ActiveConnection = objConnection objCommand.CommandText = oQuery Set objRecordSet = objCommand.Execute While not objRecordSet.EOF WScript.Echo objRecordSet.Fields("name") objRecordSet.MoveNext Wend objCOnnection.Close
2. Here the query registry code.
Dim strKeyPath Dim strComputer Dim strEntryName Dim strValue Dim strData Dim objReg Dim subKey Dim arrSubKeys Const HKLM = &H80000000 'HKEY_LOCAL_MACHINE Dim oWsh:Set oWsh = CreateObject("WScript.Shell")
strData = oWsh.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\RegisteredOrganization") If Err.Number = 0 Then WScript.Echo ("What " & strData) Else WScript.Echo ("Nothing Exist " & Now) End If
I hope the above can be put together, thanks in advance for all you help.
The second script will not read a remote computer's registry. You would need to use WMI for that. Search this forum and you will find lots of sample WMI scripts.
You are right i've created a WMI that can query registry.
Sub ListComputers Dim objRegProv Dim objWshController Dim objRemoteScript Dim strKeyPath Dim strEntryName Dim strValue Dim strValueName Dim strData Dim objReg Dim subKey Dim arrSubKeys Const HKLM = &H80000002 'HKEY_LOCAL_MACHINE Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv") strKeyPath = "SOFTWARE\Microsoft\Windows Script Host\Settings" objReg.SetStringValue HKLM, strKeyPath, "Remote", "1" strKeyPath2 = "SOFTWARE\INTEL\LanDesk\VirusProtect6\CurrentVersion" strValueName = "Parent" objReg.GetStringValue HKLM, strKeyPath2, strValueName, strData WScript.Echo ("Anti-Virus Server " & strData) If strdata = "SLONSUPP" Then WSCript.Echo ("Anti-Virus Server Correct") ElseIf strdata ="SLONSUPP06" Then WScript.Echo ("Anti-Virus Server incorrect please call x1966") ElseIf strdata ="SLONSUPP03" Then WScript.Echo ("Anti-Virus Server incorrect please call x1966") Else WScript.Echo ("No Anti-Virus Software installed") End If End Sub Dim strComputer rem Do strComputer = inputbox ("Enter hostname of pc","Input") rem if (Action ="") Then WScript.Quit rem Loop until strComputer <>"" If strComputer = "" Then WScript.Quit ListComputers
Above opens an input box but need to link this to LDAP query. Any ideas or a pointer in the right direction???