Const ForAppending = 8
Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("C:\Scripts\adobeinventory.csv", ForAppending, True)
Set objComputerList = objFSO.OpenTextFile("C:\Scripts\computers.txt",ForReading)
Set objShell = WScript.CreateObject("Wscript.Shell")
objTextFile.WriteLine "Computer Name" & "," & "Description" & "," & "Version"
Do Until objComputerList.AtEndOfStream
On Error Resume Next
strComputer = objComputerList.ReadLine
WScript.Echo "Starting " & strComputer & "..."
cmdPing = "for /f ""delims=."" %I in ('ping -n 1 "&strComputer&"') do if ""%I""==""Request timed out"" (exit 55)"
cmdReturn = objShell.run("cmd /c "+ cmdPing,0,true)
If cmdReturn=0 Then
cmdPing = "for /f ""delims=."" %I in ('ping -n 1 "&strComputer&"') do if ""%I""==""Ping request could not find host "&strComputer&""" (exit 65)"
cmdReturn = objShell.run("cmd /c "+ cmdPing,0,true)
If cmdreturn=0 Then
WScript.Echo "Ping successful."
Err.Clear
Set objComputer = GetObject("LDAP://cn=" & strComputer & ",cn=Computers,dc=domain,dc=com")
If Err.Number = 0 Then
WScript.Echo "System on the domain."
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
'Get list of software installed
WScript.Echo "Inventorying..."
Set colSoftware = objWMIService.ExecQuery ("Select * from Win32_Product where Description like '%adobe%'")
For Each objSoftware in colSoftware
objTextFile.WriteLine strComputer & "," & objSoftware.Description & "," & objSoftware.Version
Next
Set objWMIService = "Nothing"
Set colSoftware = "Nothing"
Else
WScript.Echo "System in a Workgroup."
End If
Else
WScript.Echo "Ping failed."
End If
End If
WScript.Echo strComputer & " was successfully inventoried."
Loop
objTextFile.Close
Wscript.echo "Done"
'On Error Resume Next
Const ForAppending = 8
Const ForReading = 1
Const HKEY_LOCAL_MACHINE = &H80000002
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("C:\Scripts\adobeinventory.csv", ForAppending, True)
Set objComputerList = objFSO.OpenTextFile("C:\Scripts\computers.txt",ForReading)
Set objShell = WScript.CreateObject("Wscript.Shell")
objTextFile.WriteLine "Computer Name" & "," & "Description" & "," & "Version"
Do Until objComputerList.AtEndOfStream
'On Error Resume Next
strComputer = objComputerList.ReadLine
WScript.Echo "Starting " & strComputer & "..."
cmdPing = "for /f ""delims=."" %I in ('ping -n 1 "&strComputer&"') do if ""%I""==""Request timed out"" (exit 55)"
cmdReturn = objShell.run("cmd /c "+ cmdPing,0,true)
If cmdReturn=0 Then
WScript.Echo "Ping did not time out."
cmdPing = "for /f ""delims=."" %I in ('ping -n 1 "&strComputer&"') do if ""%I""==""Ping request could not find host "&strComputer&""" (exit 65)"
cmdReturn = objShell.run("cmd /c "+ cmdPing,0,true)
If cmdreturn=0 Then
WScript.Echo "Ping successful."
Err.Clear
Set objComputer = GetObject("LDAP://cn=" & strComputer & ",cn=Computers,dc=corp,dc=ad,dc=domain,dc=com")
If Err.Number = 0 Then
WScript.Echo "System on the domain."
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colSoftware = objWMIService.ExecQuery ("Select * from Win32_Product where Description like '%adobe%'")
If Err.Number = 0 Then
If colSoftware is Nothing Then
WScript.Echo "Access Denied"
Else
'Get list of software installed
WScript.Echo "Inventorying..."
For Each objSoftware in colSoftware
objTextFile.WriteLine strComputer & "," & objSoftware.Description & "," & objSoftware.Version
Next
End If
End If
End If
Else
WScript.Echo "Ping Failed."
End If
Else
WScript.Echo "Ping Failed."
End If
Loop
objTextFile.Close
Wscript.echo "Done"
On Error Resume Next
Const ForAppending = 8
Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("C:\Scripts\adobeinventory.csv", ForAppending, True)
Set objComputerList = objFSO.OpenTextFile("C:\Scripts\computers.txt",ForReading)
Set objShell = WScript.CreateObject("Wscript.Shell")
objTextFile.WriteLine "Computer Name" & "," & "Description" & "," & "Version"
Do Until objComputerList.AtEndOfStream
On Error Resume Next
strComputer = objComputerList.ReadLine
WScript.Echo "Starting " & strComputer & "..."
cmdPing = "for /f ""delims=."" %I in ('ping -n 1 "&strComputer&"') do if ""%I""==""Request timed out"" (exit 55)"
cmdReturn = objShell.run("cmd /c "+ cmdPing,0,true)
If cmdReturn=0 Then
cmdPing = "for /f ""delims=."" %I in ('ping -n 1 "&strComputer&"') do if ""%I""==""Ping request could not find host "&strComputer&""" (exit 65)"
cmdReturn = objShell.run("cmd /c "+ cmdPing,0,true)
If cmdreturn=0 Then
WScript.Echo "Ping successful."
Err.Clear
Set objComputer = GetObject("LDAP://cn=" & strComputer & ",cn=Computers,dc=Domain,dc=com")
If Err.Number = 0 Then
WScript.Echo "System on the domain."
Set TestFile = objFSO.CreateTextFile("\\" & strComputer & "\c$\testfile.txt", True)
TestFile.WriteLine "This is a test."
TestFile.Close
Set TestFile = Nothing
If Err.Number = 0 Then
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colSoftware = objWMIService.ExecQuery ("Select * from Win32_Product where Description like '%adobe%'")
WScript.Echo "Inventorying..."
If colSoftware.Count = 0 Then
objTextFile.WriteLine strComputer & ",no Adobe applications,0"
Else
For Each objSoftware in colSoftware
objTextFile.WriteLine strComputer & "," & objSoftware.Description & "," & objSoftware.Version
Next
End If
Set objWMIService = Nothing
Set colSoftware = Nothing
Else
WScript.Echo "Access Denied"
objTextFile.WriteLine strComputer & ",Access Denied"
End If
End If
Else
WScript.Echo "Ping Failed."
objTextFile.WriteLine strComputer & ",Ping Failed"
End If
Else
WScript.Echo "Ping Failed."
objTextFile.WriteLine strComputer & ",Ping Failed"
End If
Loop
objTextFile.Close
Wscript.echo "Done"
Open in new window