Showing posts with label MY Vbscripts. Show all posts
Showing posts with label MY Vbscripts. Show all posts

Friday, October 1, 2010

Systems Part of What Collections

--Systems Part of What Collections

SELECT v_R_System.Name0, v_Collection.Name FROM v_FullCollectionMembership INNER JOIN v_R_System ON v_FullCollectionMembership.ResourceID = v_R_System.ResourceID INNER JOIN v_Collection ON v_FullCollectionMembership.CollectionID = v_Collection.CollectionID WHERE (v_R_System.Name0 = 'Systemname')

Tuesday, June 15, 2010

script that has WMI connection error will skip it and move to next

strComputer = "MYcomputername"

Set objExcel = CreateObject("Excel.Application")

objExcel.Visible = True

objExcel.Workbooks.Add

intRow = 2

objExcel.Cells(1, 1).Value = "Logon Name"

objExcel.Cells(1, 2).Value = "Full Name"

objExcel.Cells(1, 3).Value = "Description"

objExcel.Cells(1, 4).Value = "Domain"

objExcel.Cells(1, 5).Value = "Password Changeable"

objExcel.Cells(1, 6).Value = "Password Required"

objExcel.Cells(1, 7).Value = "Password Expires"

objExcel.Cells(1, 8).Value = "Account Disabled"

objExcel.Cells(1, 9).Value = "Account Locked Out"

On Error Resume Next
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
If err.Number <> 0 then
       Call Wscript.echo("Error has occurred connecting to WMI on workstation: " & strComputer)
End if

Set colItems = objWMIService.ExecQuery("Select * from Win32_UserAccount")

For Each objItem in colItems

objExcel.Cells(intRow, 1).Value = objItem.Name

objExcel.Cells(intRow, 2).Value = objItem.FullName

objExcel.Cells(intRow, 3).Value = objItem.Description

objExcel.Cells(intRow, 4).Value = objItem.Domain

If objItem.PasswordChangeable = True Then

objExcel.Cells(intRow, 5).Value = "Yes"

objExcel.Cells(intRow, 5).Font.ColorIndex = 10

Else   

objExcel.Cells(intRow, 5).Value = "No"

objExcel.Cells(intRow, 5).Font.ColorIndex = 3

End If

If objItem.PasswordRequired = True Then

objExcel.Cells(intRow, 6).Value = "Yes"

objExcel.Cells(intRow, 6).Font.ColorIndex = 10

Else   

objExcel.Cells(intRow, 6).Value = "No"

objExcel.Cells(intRow, 6).Font.ColorIndex = 3

End If

If objItem.PasswordExpires = True Then

objExcel.Cells(intRow, 7).Value = "Yes"

objExcel.Cells(intRow, 7).Font.ColorIndex = 10

Else   

objExcel.Cells(intRow, 7).Value = "No"

objExcel.Cells(intRow, 7).Font.ColorIndex = 3

End If

If objItem.Disabled = True Then

objExcel.Cells(intRow, 8).Value = "Yes"

objExcel.Cells(intRow, 8).Font.ColorIndex = 10

Else   

objExcel.Cells(intRow, 8).Value = "No"

objExcel.Cells(intRow, 8).Font.ColorIndex = 3

End If

If objItem.Lockout = True Then

objExcel.Cells(intRow, 9).Value = "Yes"

objExcel.Cells(intRow, 9).Font.ColorIndex = 10

Else   

objExcel.Cells(intRow, 9).Value = "No"

objExcel.Cells(intRow, 9).Font.ColorIndex = 3

End If

intRow = intRow + 1

Next

objExcel.Range("A1:I1").Select

objExcel.Selection.Interior.ColorIndex = 19

objExcel.Selection.Font.ColorIndex = 11

objExcel.Selection.Font.Bold = True

objExcel.Cells.EntireColumn.AutoFit

MsgBox "Done"

Excel output Script : for file version check well explained

Correct Script

Set Fso = CreateObject("Scripting.FileSystemObject")
Set InputFile = fso.OpenTextFile("MachineList.Txt")
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
objExcel.Workbooks.Add

intRow = 2
Do While Not (InputFile.atEndOfStream)
strComputer = InputFile.ReadLine

intRow = intRow +1
objExcel.Cells(1, 1).Value = "System Name"
objExcel.Cells(1, 2).Value = "Version"
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colFiles = objWMIService.ExecQuery _
    ("Select * from CIM_Datafile Where Name = 'c:\\windows\\system32\\mshtml.dll'")

For Each objFile in colFiles
objExcel.Cells(intRow, 2).Value = objFile.Version
objExcel.Cells(intRow, 1).Value = strComputer
objExcel.Range("A1:B1").Select
objExcel.Selection.Interior.ColorIndex = 19
objExcel.Selection.Font.ColorIndex = 11
objExcel.Selection.Font.Bold = True
objExcel.Cells.EntireColumn.AutoFit
Next
loop
Set objSheet = objExcel.ActiveWorkbook.Worksheets(1)
Set objRange = objExcel.Range("B1")
objRange.Sort objRange,1,,,,,,1
' loop
MsgBox "Done"

 

Wrong Script

 

 

Set Fso = CreateObject("Scripting.FileSystemObject")
Set InputFile = fso.OpenTextFile("MachineList.Txt")
Do While Not (InputFile.atEndOfStream)
strComputer = InputFile.ReadLine
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
objExcel.Workbooks.Add
intRow = 2
objExcel.Cells(1, 1).Value = "System Name"
objExcel.Cells(1, 2).Value = "Version"
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colFiles = objWMIService.ExecQuery _
    ("Select * from CIM_Datafile Where Name = 'c:\\windows\\system32\\mshtml.dll'")
For Each objFile in colFiles
objExcel.Cells(intRow, 2).Value = objFile.Version
objExcel.Cells(intRow, 1).Value = strComputer

objExcel.Range("A1:B1").Select
objExcel.Selection.Interior.ColorIndex = 19
objExcel.Selection.Font.ColorIndex = 11
objExcel.Selection.Font.Bold = True
objExcel.Cells.EntireColumn.AutoFit
Next
loop
Set objSheet = objExcel.ActiveWorkbook.Worksheets(1)
Set objRange = objExcel.Range("B1")
objRange.Sort objRange,1,,,,,,1
' loop
MsgBox "Done"

Monday, June 14, 2010

TO GET THE USER STATUS : Guest account status

 

Set Fso = CreateObject("Scripting.FileSystemObject")

Set InputFile = fso.OpenTextFile("MachineList.Txt")

Do While Not (InputFile.atEndOfStream)

strComputer = InputFile.ReadLine

strUserName = "Guest"

On Error Resume Next
Set objUser = GetObject("WinNT://" & strComputer & "/" & strUserName)

If objUser.AccountDisabled = True Then

Wscript.Echo (strUserName) & " Is Disabled On " & UCase(strComputer)

Else

MsgBox UCase(strUserName) & " Is Enabled On " & UCase(strComputer)

End If

loop

Wednesday, June 9, 2010

Batch file for loop in other way

echo ***** Are you sure you want to add these accounts? *******
echo *** If not, press CTRL-C to terminate this batch file ***
pause
FOR %%X IN (NT1 NT2 NT3 NT4 NT5) DO NET COMPUTER \\%%X /ADD
FOR %%X IN (NT6 NT7 NT8 NT9 NT10) DO NET COMPUTER \\%%X /ADD
cls
echo ******* Machine Accounts Added ********
pause

Thursday, May 13, 2010

Scripts to query installed Service Packs, Patches/updates and Hotfixes

Scripts to query installed Service Packs, Patches/updates and Hotfixes

There are many known scripts which use WMI class Win32_QuickFixEngineering to enumerate hotfixes installed on a computer. These scripts can give you a list of installed updates like;

1.

This Script reports installed updates that are installed with Windows Update (v5) technology and the result will be written to %temp%\UpdateHistory.txt and then launched in Notepad.

USAGE: Cscript //nologo WUhistory.vbs

The output will look like;

Report run at 4/23/2006 2:42:14 PM
------------------------------------------------------------------
Title:   Security Update for Windows XP (KB908531)
Description:  A security issue has been identified in Windows Explorer that could allow an attacker to compromise your Windows-based system and gain control over it. You can help protect your computer by installing this update from Microsoft. After you install this item, you may have to restart your computer.
Date/Time in GMT: 4/18/2006 7:47:14 AM
Install mechanism: AutomaticUpdates
Install status:  Succeeded
------------------------------------------------------------------

'--------------------8<----------------------
' Script that reports installed updates that are
' installed with Windows Update v5 technology
'
' Result will be written to %temp%\UpdateHistory.txt
' and then launched in Notepad
'
' Author: Torgeir Bakken
' Date 2004-08-12
'
Option Explicit

Const OverwriteIfExist = -1
Const OpenAsASCII   =  0

Dim oWU, iTHCount, colUpdate, oUpdate, sStatus, iTotal
Dim iSuccess, iFailed, iAborted, iUnknown, sErrorCode
Dim oFSO, oShell, sFile, f

On Error Resume Next
Set oWU = CreateObject("Microsoft.Update.Searcher")

If Err.Number <> 0 Then
   MsgBox "WU5 programming interface does not exist.", _
          vbInformation + vbSystemModal, "Update history"
   WScript.Quit
End If
On Error Goto 0

iTHCount = oWU.GetTotalHistoryCount
If iTHCount > 0 Then

   Set oFSO = CreateObject("Scripting.FileSystemObject")
   Set oShell = CreateObject("Wscript.Shell")
   sFile = oShell.ExpandEnvironmentStrings("%TEMP%") & "\UpdateHistory.txt"
   Set f = oFSO.CreateTextFile(sFile, _
                      OverwriteIfExist, OpenAsASCII)

   iTotal = 0
   iSuccess = 0
   iFailed = 0
   iAborted = 0
   iUnknown = 0

   f.WriteLine "Report run at " & Now
     f.WriteLine "---------------------------------" _
           & "---------------------------------"

   Set colUpdate = oWU.QueryHistory(0, iTHCount)

   For Each oUpdate In colUpdate
     f.WriteLine "Title:" & vbTab & vbTab & vbTab & oUpdate.Title
     f.WriteLine "Description:" & vbTab & vbTab & oUpdate.Description
     f.WriteLine "Date/Time in GMT:" & vbTab & oUpdate.Date
     f.WriteLine "Install mechanism:" & vbTab & oUpdate.ClientApplicationID

     sErrorCode = ""
     Select Case oUpdate.ResultCode
       Case 2
         sStatus = "Succeeded"
         iSuccess = iSuccess + 1
       Case 4
         sStatus = "Failed"
         iFailed = iFailed + 1
         sErrorCode = oUpdate.UnmappedResultCode
       Case 5
         sStatus = "Aborted"
         iAborted = iAborted + 1
       Case Else
         sStatus = "Unknown"
         iUnknown = iUnknown + 1
     End Select

     If sStatus = "Failed" Then
       f.WriteLine "Install error:" & vbTab & vbTab & sErrorCode
     End If

     f.WriteLine "Install status:" & vbTab & vbTab & sStatus
     f.WriteLine "---------------------------------" _
           & "---------------------------------"

     iTotal = iTotal + 1
   Next

   f.WriteLine
   f.WriteLine "Total number of updates found: " & iTotal
   f.WriteLine "Number of updates succeeded: " & iSuccess
   f.WriteLine "Number of updates failed: " & iFailed
   f.WriteLine "Number of updates aborted: " & iAborted

   f.Close
   oShell.Run "notepad.exe " & """" & sFile & """", 1, False
Else

   MsgBox "No entries found in Update History.", _
          vbInformation + vbSystemModal, "Update history"

End If
'--------------------8<----------------------

2.

This script enumerate hotfixes installed on a computer and outputs some computer information.

USAGE: Cscript //nologo HotfixHistory.vbs > HotfixHistory.txt

The output will look like;

Hotfix report date: 4/23/2006 2:45:19 PM

OS version: Microsoft Windows XP Professional
SP version: Service Pack 2
OS language: English

HotFixID: KB873339
Description: Windows XP Hotfix - KB873339
InstalledBy: Administrator
InstallDate: 12/11/2005

'
' Description: Script that outputs some computer information
' and lists all installed hotfixes including installation date
'
' Author: Torgeir Bakken
' Date: 2004-10-19
'

Wscript.Echo "Hotfix report date: " & Now & vbCrLf

strComputer = "."   ' use "." for local computer

Const HKLM = &H80000002

'On Error Resume Next
Set objWMIService = GetObject("winmgmts:" _
        & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colSettings = objWMIService.ExecQuery _
        ("Select * from Win32_OperatingSystem")

' get general info about the OS

' Caption value for different OS:
' Microsoft Windows 2000 ...
' Microsoft Windows XP ...
' Microsoft(R) Windows(R) Server 2003, ..... Edition
For Each objOperatingSystem in colSettings
    strOSCaption = objOperatingSystem.Caption
    Select Case True
      Case InStr(1, strOSCaption, "windows 2000", vbTextCompare) > 0
        strOS = "Windows 2000"
      Case InStr(1, strOSCaption, "windows xp", vbTextCompare) > 0
        strOS = "Windows XP"
      Case InStr(1, strOSCaption, "windows(r) server 2003", vbTextCompare) > 0
        strOS = "Windows Server 2003"
    End Select

    intOSLang = objOperatingSystem.OSLanguage
    strOSLangHex = Right("000" & Hex(intOSLang), 4)
    strOSServicePack = objOperatingSystem.CSDVersion
Next

Set objReg = GetObject("WinMgmts:{impersonationLevel=impersonate}!//" _
              & strComputer & "/root/default:StdRegProv")

strOSLanguage = "Unknown"  ' Init value
strKeyPath = "SOFTWARE\Classes\MIME\Database\Rfc1766"
strValueName = strOSLangHex
objReg.GetStringValue HKLM, strKeyPath, strValueName, strOSLanguage

' remove unnecessary stuff
arrOSLanguage = Split(strOSLanguage, ";")
strOSLanguage = arrOSLanguage(UBound(arrOSLanguage))
If Instr(strOSLanguage, "(") > 0 Then
    arrOSLanguage = Split(strOSLanguage, "(")
    strOSLanguage = Trim(arrOSLanguage(0))
End If

Wscript.Echo "OS version: " & strOSCaption
Wscript.Echo "SP version: " & strOSServicePack
Wscript.Echo "OS language: " & strOSLanguage

' start enumeration of hotfixes

Wscript.Echo vbCrLf & "Hotfixes Identified:"

strRegBaseUpdate = "SOFTWARE\Microsoft\Updates\" & strOS

Set colItems = objWMIService.ExecQuery _
        ("Select * from Win32_QuickFixEngineering",,48)

For Each objItem in colItems
    If objItem.HotFixID <> "File 1" Then
       Wscript.Echo "HotFixID: " & objItem.HotFixID
       Wscript.Echo "Description: " & objItem.Description
       Wscript.Echo "InstalledBy: " & objItem.InstalledBy
       strInstallDate = Null  ' init value
       If objItem.ServicePackInEffect <> "" Then
          strRegKey = strRegBaseUpdate & "\" & objItem.ServicePackInEffect _
                 & "\" & objItem.HotFixID
          objReg.GetStringValue HKLM, strRegKey, _
               "InstalledDate", strInstallDate
       End If

       If IsNull(strInstallDate) Then
          strInstallDate = "(none found)"
       End If
       Wscript.Echo "InstallDate: " & strInstallDate
       Wscript.Echo   ' blank line
    End If
Next
'--------------------8<----------------------

3.

I found this script in the community. Worth a try!

'--------------------8<----------------------

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colQuickFixes = objWMIService.ExecQuery _
    ("Select * from Win32_QuickFixEngineering")
For Each objQuickFix in colQuickFixes
    Wscript.Echo "Computer: " & objQuickFix.CSName
    Wscript.Echo "Description: " & objQuickFix.Description
    Wscript.Echo "Hot Fix ID: " & objQuickFix.HotFixID
    Wscript.Echo "Installation Date: " & objQuickFix.InstallDate
    Wscript.Echo "Installed By: " & objQuickFix.InstalledBy
Next

'--------------------8<----------------------

4.

Very recently, I found this GUI utility by name WinUpdatesList.

  • WinUpdatesList displays the list of all Windows updates (Service Packs and Hotfixes) installed on your local computer.
  • For hotfix updates, this utility also displays the list of files updated with these hotfixes.
  • In addition, it allows you to instantly open the Web link in Microsoft Web site that provides more information about the selected update, uninstall an update, copy the update information to the clipboard, or save it to text/HTML/XML file.

5.

You can also query list of updates /hotfixes installed by this simple command (one line). Replace 'server-name' with your server or your machine name;

wmic /node:'server-name' qfe GET description,FixComments,hotfixid,installedby,installedon,servicepackineffect

You can also output the result to a text / csv file;

wmic /node:'server-name' qfe GET description,FixComments,hotfixid,installedby,installedon,servicepackineffect > QFElist.txt

Saturday, May 8, 2010

create 1000 users

' Create 1000 Sample User Accounts


Set objRootDSE = GetObject("LDAP://rootDSE")

Set objContainer = GetObject("LDAP://cn=Users," & _
objRootDSE.Get("defaultNamingContext"))

For i = 1 To 1000
Set objLeaf = objContainer.Create("User", "cn=UserNo" & i)
objLeaf.Put "sAMAccountName", "UserNo" & i
objLeaf.SetInfo
Next

WScript.Echo "1000 Users created."

'Below script to create number of computers in AD--for testing

'Below script to create number of computers in AD--for testing

'==============================================================================
'
' Description: This script creates multiple sequential computer accounts
' in an AD OU. It appends a 3 digit number to the base name starting with
' the number entered at the prompt.
' ==============================================================================
Option Explicit
'Define Constants
Const ADS_SCOPE_ONELEVEL = 1
'Declare Variables
Dim DQ
Dim strAdmin
Dim intRecord
Dim objShell
Dim objNetwork
Dim intWarn
Dim objRootDSE
Dim strADsPath
Dim objConnection
Dim objCommand
Dim strOUPath
Dim objRecordSet
Dim strBaseName
Dim intRecordMax
Dim bEnabled
Dim objOU
Dim strNewComputerName
Dim objNewComputer
Dim strDomainDN
Dim strDomainFQDN
Dim intOULevel
Dim strSearchADsPath
Dim intStartNumber
'Set variables
DQ = Chr(34)
'Create Objects
Set objShell = CreateObject("Wscript.Shell")
Set objNetwork = CreateObject("WScript.NetWork")
'Verifies script was run using Cscript, and if not relauches it using Cscript
If Not WScript.FullName = WScript.Path & "\cscript.exe" Then

objShell.Popup "Relaunching script with Cscript in 5 seconds...", 5, _
"Script Host Message", 48

objShell.Run "cmd.exe /k " & WScript.Path & "\cscript.exe //NOLOGO " & _
DQ & WScript.scriptFullName & DQ, 1, False

Script.Quit 0
End If

'Warn User
intWarn = MsgBox("This will make changes to AD." & VbCr & _
"Are you sure you want to do this?", 308, "ID 10 T Check")
'308 = Yes/No (4) + 'Exclaimation (48) + Default Button 2 (256)
If intWarn = vbNo Then

WScript.Quit 0
End If
'Construct an ADsPath to the Current Domain with rootDSE
Set objRootDSE = GetObject("LDAP://rootDSE")
strADsPath = "LDAP://" & objRootDSE.Get("defaultNamingContext")
'Convert domain Distinguished Name to FQDN format
strDomainDN = objRootDSE.Get("defaultNamingContext")
strDomainFQDN = Replace(Replace(strDomainDN, "DC=", ""), ",", ".")
'Connect to Active Directory
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_ONELEVEL
'Prompt for Path to OU
Do

strOUPath = _
InputBox("Please enter the path to the OU where the computer accounts " & _
" will be created - Seperate OUs With a \", "OU Path Input", "TopOU\SubOU")
If strOUPath = False Then
WScript.Quit

End If
Loop Until strOUPath <> ""


'Split OU path by OU
strOUPath = UCase(strOUPath)
strOUPath = Split(strOUPath, "\")


'Prepare variables for search
intOULevel = 0
strSearchADsPath = strADsPath


'Search through each OU level in path provided
For intOULevel = 0 To UBound(strOUPath)

objCommand.CommandText = "SELECT ADsPath FROM '" & strSearchADsPath & _
"'" & " WHERE objectCategory='organizationalUnit' AND Name = '" & _
strOUPath(intOULevel) & "'"

Set objRecordSet = objCommand.Execute

'Verify OU was found

If objRecordSet.EOF Then

WScript.echo "OU named " & strOUPath(intOULevel) & _
" not found, Exiting script."

WScript.quit

Else

objRecordSet.MoveFirst
Do Until objRecordSet.EOF
strSearchADsPath = objRecordSet.Fields("ADsPath").Value
objRecordSet.MoveNext
Loop
End If
Next
'Get current username to use in description field
strAdmin = objNetwork.UserName
'Prompt for the base computer name
Do
strBaseName = _
InputBox("Please enter the base computer name to use for new accounts:", _
"Base Computer Name", "TestPC")
If strBaseName = False Then
WScript.Quit
End If
Loop Until strBaseName <> ""
strBaseName = UCase(strBaseName)
'Prompt for starting computer number
Do

intStartNumber = _
InputBox("Please enter the beginning number to use in computer names:", _
"Starting Computer Number", "001")
If intStartNumber = False Then

WScript.Quit

End If
Loop Until intStartNumber <> ""
intStartNumber = CInt(intStartNumber)
intRecord = intStartNumber
'Prompt for number of accounts to be created
Do

intRecordMax = _
InputBox("Please enter the number of accounts to be created", _
"Count Input", "10")
If intRecordMax = False Then

WScript.Quit

End If
Loop Until intRecordMax <> ""
intRecordMax = CInt(intRecordMax)


'Bind to OU that computers will be created in
Set objOU = GetObject(strSearchADsPath)

'Create the user accounts
Do Until intRecord = intRecordMax + intStartNumber
intRecord = Right("000" & intRecord, 3)
strNewComputerName = strBaseName & intRecord
WScript.Echo "Creating " & strNewComputerName
Set objNewComputer = objOU.Create("Computer", "cn= " & strNewComputerName)
objNewComputer.Put "samAccountName", strNewComputerName & "$"
objNewComputer.Put "userAccountControl", 4096
objNewComputer.Put "description", "Account created: " & Date() & " by: " _
& strAdmin
objNewComputer.SetInfo 'Writes settings to AD
intRecord = intRecord + 1
Loop

WScript.Echo
WScript.echo "Finished creating computer accounts."

Wednesday, April 7, 2010

You want to stop unwanted things while loading or want to get control of boot load files??

Ohh.. my systems dead slow after joins here… they given me T61 with 1 GB..  Where my system taking more than 1 Gb almost every time I am working my Page file…. 

image

I checked this utility, which has the most comprehensive knowledge of auto-starting locations of any startup monitor, shows you what programs are configured to run during system bootup or login, and shows you the entries in the order Windows processes them. These programs include ones in your startup folder, Run, RunOnce, and other Registry keys. You can configure Autoruns to show other locations, including Explorer shell extensions, toolbars, browser helper objects, Winlogon notifications, auto-start services, and much more. Autoruns goes way beyond the MSConfig utility bundled with Windows Me and XP.

Autoruns' Hide Signed Microsoft Entries option helps you to zoom in on third-party auto-starting images that have been added to your system and it has support for looking at the auto-starting images configured for other accounts configured on a system. Also included in the download package is a command-line equivalent that can output in CSV format, Autorunsc.

You'll probably be surprised at how many executables are launched automatically!

 

Here is the link to download http://live.sysinternals.com/autoruns.exe

Sunday, February 7, 2010

VBSCRIPT FILE VERSION ON LIST OF SYSTEMS TO EXCEL


Set Fso = CreateObject("Scripting.FileSystemObject")

Set InputFile = fso.OpenTextFile("MachineList.Txt")

Do While Not (InputFile.atEndOfStream)

strComputer = InputFile.ReadLine

Set objExcel = CreateObject("Excel.Application")

objExcel.Visible = True

objExcel.Workbooks.Add

intRow = 2
objExcel.Cells(1, 1).Value = "System Name"

objExcel.Cells(1, 2).Value = "Version"

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

Set colFiles = objWMIService.ExecQuery _
    ("Select * from CIM_Datafile Where Name = 'c:\\windows\\system32\\mshtml.dll'")

For Each objFile in colFiles
objExcel.Cells(intRow, 2).Value = objFile.Version
objExcel.Cells(intRow, 1).Value = strComputer


objExcel.Range("A1:B1").Select

objExcel.Selection.Interior.ColorIndex = 19

objExcel.Selection.Font.ColorIndex = 11

objExcel.Selection.Font.Bold = True

objExcel.Cells.EntireColumn.AutoFit

 Next
loop

Set objSheet = objExcel.ActiveWorkbook.Worksheets(1)

Set objRange = objExcel.Range("B1")

objRange.Sort objRange,1,,,,,,1

' loop

MsgBox "Done"

''''''''''''''''''''''''''''''' THIS SCRIPT IS NOT WORKING AS EXPECTING IT IS OPENING MANY EXCEL FILES WITH CORRECT OUTPUT.. ANYWAY IT MIGHT USEFULL TO ME
-------------------
Thanks,

Mike Ditka  - "If God had wanted man to play soccer, he wouldn't have given us arms."

VBSCRIPT FOR FILE VERSION CHECK

 

Set Fso = CreateObject("Scripting.FileSystemObject")

Set InputFile = fso.OpenTextFile("MachineList.Txt")

Do While Not (InputFile.atEndOfStream)

strComputer = InputFile.ReadLine

 

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

Set colFiles = objWMIService.ExecQuery _
    ("Select * from CIM_Datafile Where Name = 'c:\\windows\\system32\\drivers\\tdx.sys'")
For Each objFile in colFiles
    Wscript.Echo objFile.Version &" " & strComputer
   
    'Wscript.Echo "Version: " & strComputer

Next

loop
-------------------
Thanks,

Marie von Ebner-Eschenbach  - "Even a stopped clock is right twice a day."

Thursday, January 21, 2010

Easy way to to make script to accept list of systems from a text file where you have strComputer = "." script

Easy way to to make script to accept list of systems from a text file where you have strComputer = "." script

 


Set Fso = CreateObject("Scripting.FileSystemObject")

Set InputFile = fso.OpenTextFile("MachineList.Txt")

Do While Not (InputFile.atEndOfStream)

strComputer = InputFile.ReadLine

loop

When you get the strComputer = "." and you want to accept the list from a txt file then above will be use full
-------------------
Thanks,

Charles de Gaulle  - "The better I get to know men, the more I find myself loving dogs."