Hi All
I hope someone would be able to help me out here. I am not a programmer but can put together some code to get what I need. I have a list of computers in a text file. I am trying to read the add/Remove program and if match one apps then it write the computer name in a text file such as "exist.txt" and also write the computer name those are not online to another text file name "Notonline.txt" What I am not able to produce is another text file that will show all the computer name those does not have that particular app installed. I am using
("SELECT * FROM Win32_Product where Name = 'appsName')
for each objitem in colitems
so and so
It works fine but I just can not produce the computer list that does not have the apps installed.
Anyhelp would be much appreciated.
Here is my current code:
On error Resume Next
Const ForReading = 1
Const OverwriteExisting = True
OutputFile="Exist.txt"
OutputFile2="NotOnline.txt"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFSO2 = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.CreateTextFile(OutputFile, True)
Set objFile2 = objFSO2.CreateTextFile(OutputFile2, True)
strInputFile = "4.txt"
set objFSO1=createobject("scripting.filesystemobject")
set objFile1=objFSO.opentextfile(strInputFile)
do until objFile1.atendofstream
strComputer=objFile1.readline
If Ping(strComputer) = True Then
Set filesys = CreateObject("Scripting.FileSystemObject")
if filesys.FolderExists("\\" & strComputer & "\Admin$\System32") then
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_Product where Name = 'Flow'")
For Each objItem In colItems
objFile.WriteLine (""& strComputer)
Next
Else
objFile.WriteLine ("Access Denied :" & strComputer)
End if
Else
objFile2.WriteLine ("" & strComputer)
End If
Loop
Function Ping(strComputer)
sHost = "."
Set cPingResults = GetObject("winmgmts:{impersonationLevel=impersonate}//" & _
sHost & "/root/cimv2"). ExecQuery("SELECT * FROM Win32_PingStatus " & _
"WHERE Address = '" + strComputer + "'")
For Each oPingResult In cPingResults
If oPingResult.StatusCode = 0 Then
Ping = True
Else
Ping = False
End If
Next
End Function
msgbox "Done"
I hope someone would be able to help me out here. I am not a programmer but can put together some code to get what I need. I have a list of computers in a text file. I am trying to read the add/Remove program and if match one apps then it write the computer name in a text file such as "exist.txt" and also write the computer name those are not online to another text file name "Notonline.txt" What I am not able to produce is another text file that will show all the computer name those does not have that particular app installed. I am using
("SELECT * FROM Win32_Product where Name = 'appsName')
for each objitem in colitems
so and so
It works fine but I just can not produce the computer list that does not have the apps installed.
Anyhelp would be much appreciated.
Here is my current code:
On error Resume Next
Const ForReading = 1
Const OverwriteExisting = True
OutputFile="Exist.txt"
OutputFile2="NotOnline.txt"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFSO2 = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.CreateTextFile(OutputFile, True)
Set objFile2 = objFSO2.CreateTextFile(OutputFile2, True)
strInputFile = "4.txt"
set objFSO1=createobject("scripting.filesystemobject")
set objFile1=objFSO.opentextfile(strInputFile)
do until objFile1.atendofstream
strComputer=objFile1.readline
If Ping(strComputer) = True Then
Set filesys = CreateObject("Scripting.FileSystemObject")
if filesys.FolderExists("\\" & strComputer & "\Admin$\System32") then
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_Product where Name = 'Flow'")
For Each objItem In colItems
objFile.WriteLine (""& strComputer)
Next
Else
objFile.WriteLine ("Access Denied :" & strComputer)
End if
Else
objFile2.WriteLine ("" & strComputer)
End If
Loop
Function Ping(strComputer)
sHost = "."
Set cPingResults = GetObject("winmgmts:{impersonationLevel=impersonate}//" & _
sHost & "/root/cimv2"). ExecQuery("SELECT * FROM Win32_PingStatus " & _
"WHERE Address = '" + strComputer + "'")
For Each oPingResult In cPingResults
If oPingResult.StatusCode = 0 Then
Ping = True
Else
Ping = False
End If
Next
End Function
msgbox "Done"