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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

autoping

Status
Not open for further replies.

Mikeesc

IS-IT--Management
Aug 20, 2007
5
BE
I have a script that pings a range of adresses and then puts them in a file (ip , hostname)

now i would like the script to add the serial number , the username and which service pack it runs .

The user profiles have no admin rights
can some give me a direction

this is what i have so far

TempFilename = "c:\IPtemp.txt"
outputfile = "c:\output.txt"
startip = "193.53.107.2"
endip = "193.53.107.10"
notfound = " ?"
tab = ","


LF = chr(10)
const ForReading = 1,ForWriting = 2,ForAppending = 3

currentIP = startIP
set shell = CreateObject ("wscript.shell")
Set FS = CreateObject ("scripting.FileSystemObject")
set fx = fs.OpenTextFile(outputfile,ForWriting)

while currentIP <> endIP
command = "cmd /C ping -a " & currentIP & " > " & TempFilename
x = shell.run(command,0,true)
set f = fs.OpenTextFile(tempfilename,ForReading,true)
fline = f.readline
fline = f.readline

l1 = instr (fline," ")
l2 = instr (fline,"[")
if l2 = 0 then
mname = notfound
else
mname = mid (fline,l1,l2-l1)
end if

fxline = currentIP & tab & mname
f.close
fx.writeline(fxline)
zz = currentIP
currentIP = newIP(zz)
wend

fx.close
wscript.echo "Massive ping is ready"


'------------
'function for increasing the IP number
'------------
function newip(xx)
dim n,n1,n2,n3,n4,v1,v2,v3,v4
n = 1
n0 = n

while mid (xx,n,1) <> "."
n =n +1
wend

n1 = n
n = n+1

while mid (xx,n,1) <> "."
n = n+1
wend

n2 = n
n = n+1

while mid (xx,n,1) <> "."
n = n+1
wend

n3 = n
n4 = len(xx)
v1 = mid (xx,n0,n1-1)
v2 = mid (xx,n1+1,n2-n1-1)
v3 = mid (xx,n2+1,n3-n2-1)
v4 = mid (xx,n3+1,n4-n3)
v4 = v4+1

if v4 >255 then
v3 = v3+1
v4 = 0
end if

if v3 > 255 then
v2 = v2+1
v3 = 0
v4 = 0
end if

if v2 > 255 then
v1 = v1+1
v2 = 0
v3 = 0
v4 = 0
end if

return = (v1 & "." & v2 & "." & v3 & "." & v4)
newIP = return
end function
 
Connect to the remote system using WMI to gather the machine name and OS/SP information.

Code:
strComputer = "127.0.0.1"
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

report = report & "******************************************" & vbCrLf & vbCrLf

Set colItems = objWMIService.ExecQuery ("Select * from Win32_ComputerSystem")
For Each objItem in colItems
     report = report & "Computer Name: " & objItem.Name & vbCrLf
Next


Set colSMBIOS = objWMIService.ExecQuery ("Select * from Win32_SystemEnclosure")
For Each objSMBIOS in colSMBIOS
    If Len(objSMBIOS.SerialNumber) > 1 Then
                report = report &  "Service Tag: "  & objSMBIOS.SerialNumber & vbCrLf
    End If
Next

Set colItems = objWMIService.ExecQuery("Select * from Win32_ComputerSystem",,48)
For Each objItem in colItems
     report = report & "Manufacturer: " & objItem.Manufacturer & vbCrLf
     report = report & "Model: " & objItem.Model & vbCrLf
Next

Set colItems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem",,48)
For Each objItem in colItems
	report = report &  "OS Info: " & objItem.Name & vbCrLf
	report = report &  "WindowsDirectory: " & objItem.WindowsDirectory & vbCrLf
    report = report &  "Version: " & objItem.Version & vbCrLf
    report = report &  "ServicePackMajorVersion: " & objItem.ServicePackMajorVersion & vbCrLf
Next

WScript.Echo report

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
How do get type of CPU and number of CPU information and memory size ?

Thank you.
 
Number of CPUs is tricky with OSes older than Vista because dual core systems look like more than one physical CPU. You have to use a dictionary object to look for unique processors.

With both CPU and memory you can use WMI. Download a copy of Scriptomatic from Microsoft to get the basic code to start with.

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top