473,386 Members | 1,745 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

How to querry network for machines running the .NET runtime?

I am trying to find out what percentage of machines on my network have the
..NET runtime installed. What would be the best reccomendation for this
(other than SMS)?

Is using WSH & WMI an answer? Can anyone point me in te right direction?
Jul 21 '05 #1
1 1538
I came up with a solution. Whether or not it's the best one, I don't know,
but it works.

Steps:

1) Export list of computer names from a container or query in Active
Directory Users and Computers.

2) Run script

'copy and paste this into the command window and hit enter

'be sure to change the paths if necessary

cscript "<ScriptPath>\<ScriptName>.vbs" "<FilePath>" "<HostFileName>"
"<LogFileName>" 1

3) View Log

The script:

#######################################

Dim strLogMessage

Dim strIpFile

Dim strLogFile

Dim strPath

Dim intExtendedLog

strLogMessage=""

strIpFile=""

strLogFile=""

strPath=""

intExtendedLog=0

On Error Resume Next

' Check Script Engine

If right(ucase(wscript.FullName),11)="WSCRIPT.EXE" Then

strLogMessage = strLogMessage & LogMessage( "ERROR: You must run this
script using cscript, for example 'cscript " & wscript.scriptname & "'.", 1,
1 )

wscript.quit 0

End If

' Check USAGE

If wscript.arguments.count <> 4 Then

strLogMessage = strLogMessage & LogMessage( "Usage: cscript " &
wscript.scriptname & " <Path> <IpFile.txt> <LogFile> <ExtendedLog>" & vbCrLf
& vbCrLf & _

" <Path> must be a full path of a folder that contains all of these
files:" & vbCrLf & _

" " & strIpFile & vbCrLf & _

" " & strLogFile & vbCrLf , 1, 1 )

wscript.quit

End If

' Set Command Switch Variables

strPath = wscript.arguments(0)

strIpFile = wscript.arguments(1)

strLogFile = wscript.arguments(2)

intExtendedLog = wscript.arguments(3)

If intExtendedLog<>"0" Then

intExtendedLog=1

Else

intExtendedLog=0

End If

' Verify that ipfile is accessible.

Set onet = createobject("wscript.network")

Set ofs = createobject("scripting.filesystemobject")

Set oipFile = ofs.opentextfile(strIpFile, 1, false)

If (Err.Number <> 0) Then

strLogMessage = strLogMessage & LogMessage( "Cannot open " & strIpFile,
1, 1 )

wscript.quit

End If

' Make sure to end with a \ character.

If Right(strPath, 1) <> "\" Then

strPath = strPath & "\"

End If

Set osvcLocal = getobject("winmgmts:root\cimv2")

'The error-handling code is below the function that may throw one - execute
it.

On Error Resume Next

While Not oipFile.atEndOfStream

ip = oipFile.ReadLine()

ip = Trim( ip )

strLogMessage = strLogMessage & LogMessage( "Connecting to " & ip &
"...", 0, intExtendedLog )

Err.Clear

Set osvcRemote =
GetObject("winmgmts:{impersonationLevel=impersonat e}\\" & ip &
"\root\cimv2")

If (Err.Number <> 0) Then

strLogMessage = strLogMessage & LogMessage( "Failed to connect to
" & ip & ".", 1, intExtendedLog )

Else

'exeCorrectPatch = detectOSVersion( osvcRemote )

'if (exeCorrectPatch <> "") then

' Lay the bits on the remote computer.

strLogMessage = strLogMessage & LogMessage( "Checking for
..NET Runtime " & exeCorrectPatch & "...", 0, intExtendedLog )

strLogMessage = strLogMessage &
LogMessage( ip & vbtab & FindTheRuntime( osvcRemote, ip ), 1,
intExtendedLog )

strLogMessage = strLogMessage &
LogMessage( "Check Complete.", 0, intExtendedLog )

'End If

End If ' Do the next IP address, then the next IP address...

'short delay

wscript.Sleep 500 ' Sleep one half second.

Wend

oipFile.close()

Set oipFile = Nothing

strLogMessage = strLogMessage & LogMessage( "Script complete. Exiting.", 0,
intExtendedLog )

'commit the log info to a file

Set logFile = CreateObject("scripting.filesystemobject")

Set oFileStream = logFile.CreateTextFile( strPath & strLogFile, True )

oFileStream.Write( strLogMessage )

oFileStream.Close()

Set oFileStream = Nothing

Set logFile = Nothing

Function FindTheRuntime( osvcRemote, ip )

strRuntime="Microsoft .NET Framework"

bFound=False

For Each Process In osvcRemote.InstancesOf("Win32_product")

If InStr( 1, Process.Name, strRuntime, 1 )>0 Then

bFound=True

Exit For

End If

Next

FindTheRuntime = bFound

End Function

Function detectOSVersion( osvcRemote )

Dim systemType

systemType="do it"

set oOSInfo = osvcRemote.InstancesOf("Win32_OperatingSystem")

'Only one instance is ever returned (the currently active OS), even
though the following is a foreach.

For Each objOperatingSystem In oOSInfo

If (objOperatingSystem.OSType <> 18) Then

' Make sure that this computer is Windows NT-based.

strLogMessage = strLogMessage & LogMessage( ip & " is not a
Windows XP, Windows 2000, or Windows 2003 Server computer.", 0,
intExtendedLog )

Else

systemType = objOperatingSystem.Version

End If

Next

detectOSPatch = systemType

End Function

Function LogMessage( theMessage, isMandatoryMessage, useExtendedLog )

If isMandatoryMessage=1 OR useExtendedLog=1 Then

wscript.echo theMessage

LogMessage = vbcrlf & theMessage

Else

wscript.echo theMessage

LogMessage = ""

End If

End Function

#######################################


"Mike S" <ms***@pac.odedodea.edu> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
I am trying to find out what percentage of machines on my network have the
.NET runtime installed. What would be the best reccomendation for this
(other than SMS)?

Is using WSH & WMI an answer? Can anyone point me in te right direction?

Jul 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Chucker | last post by:
Hi Folks, I got an Auto-Updating Application that is supposed to download all the assemblies needed from a deployment machine when started. Here ist the Code for the Launcher that has to be...
4
by: Matt Dockerty | last post by:
Hi, I'm trying to connect to a network share using a username / password / domain of my choosing. I've tried the WindowsIdentity.Impersonate route but can only impersonate the users on the...
10
by: Woody Splawn | last post by:
I have been developing a ClientServer application on one machine at my office but the time has come to transfer it to the customer. The customer is running a Windows 2000 local area network. I...
1
by: Mike S | last post by:
I am trying to find out what percentage of machines on my network have the ..NET runtime installed. What would be the best reccomendation for this (other than SMS)? Is using WSH & WMI an answer?...
3
by: cj | last post by:
I have a program (soap client that also uses sql server stored procs) that I built and tested on my c: and it works great. It was decided it should be put on the network drive. I copied...
2
BradHodge
by: BradHodge | last post by:
Reading a post regarding network security on a linked database, I saw this post by PDog on number of users in a network Environment... I am about to put a very small database (2200 kb back-end)...
1
by: ekynox | last post by:
Hi guys, have been playing with WMI to add a network printer connection to a Windows XP pc. My environment consists of a server running Windows Server 2003 and Visual Studio 2005 and a test pc...
1
by: 2boysnus | last post by:
I set up a network at my work last week and we have been having some problems that I have not ben able to fix. We have: 2 New computers running Windows XP 2 New Computers running Windows Vista...
1
by: Bhrionn | last post by:
Hello World, I am working on implementing a build for my companies application. The scenario implemeted is producing the error: ‘Class does not support automation or does not support expected...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.