none
VBScript to search PST files on a list of computers RRS feed

  • Question

  • Hello guys,

    Not-even-close-to-expert to scripting, i've been in charge to develop a script, only in VBS or batch file, that can do the following:

    - Search a list of pre-determined computers and specific path (example: \\computer\c:\<random folder>\<random folder> for only *.pst files, if not, returns an information saying that it doesnt have any file present.

    - Export that list to excel by date created, date last modified, size, attributes and path

    I've search and compiled a vbs that does something like what i want, but it extracts all the files except the specific file i want and it lacks the string/syntax to point for the list of computers and their specific path.

    Here's the VBS i've managed to compile:

    ==========================================================

    Dim strFolder, objFSO, objFolder
    Dim strExcelPath, objExcel, objSheet, intRow

    Const xlExcel7 = 39

    ' Specify main folder.
    strFolder = "C:\Program Files"

    ' Retrieve folder object.
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objFolder = objFSO.GetFolder(strFolder)

    ' Specify spreadsheet to be created.
    strExcelPath = "C:\get_pst_info.xls"

    ' Create workbook.
    Set objExcel = CreateObject("Excel.Application")
    objExcel.Workbooks.Add

    ' Bind to worksheet.
    Set objSheet = objExcel.ActiveWorkbook.Worksheets(1)

    objExcel.Cells(1, 1).Value = "Nome"
     
    objExcel.Cells(1, 2).Value = "Ficheiro"

    objExcel.Cells(1, 3).Value = "Data Criação"

    objExcel.Cells(1, 4).Value = "Data Última Modificação"

    objExcel.Cells(1, 5).Value = "Atributos"

    objExcel.Cells(1, 6).Value = "Tamanho (bytes)"

    objExcel.Cells(1, 7).Value = "Caminho"


    objExcel.Range("A1:B1:C1:D1:E1:F1:G1").Select

    objExcel.Range("A1:G1").Columns.AutoFit

    objExcel.Range("A2:G2").Rows.Autofit
     
    objExcel.Selection.Interior.ColorIndex = 19
     
    objExcel.Selection.Font.ColorIndex = 11
     
    objExcel.Selection.Font.Bold = True


    ' Enumerate files.
    intRow = 0
    Call GetFiles(objFolder)

    ' Save spreadsheet, close workbook, and quit Excel.
    objExcel.ActiveWorkbook.SaveAs strExcelPath, xlExcel7
    objExcel.ActiveWorkbook.Close
    objExcel.Application.Quit

    ' Alert user.
    Wscript.Echo "Done"

    Sub GetFiles(ByVal objParent)
      ' Enumerate files in folder.
      ' Variable intRow must have global scope.
      Dim objFile, objChild

      For Each objFile In objParent.Files
        intRow = intRow + 2
        objSheet.Cells(intRow, 1).value = objFile.Name
        objSheet.Cells(intRow, 2).value = objFile.Type
        objSheet.Cells(intRow, 3).value = objFile.DateCreated
        objSheet.Cells(intRow, 4).Value = objFile.DateLastModified
        objSheet.Cells(intRow, 5).value = objFile.Attributes
        objSheet.Cells(intRow, 6).value = objFile.Size
        objSheet.Cells(intRow, 7).Value = objFile.Path 
      Next

      ' Recurse through nested folders.
      For Each objChild In objParent.SubFolders
        Call GetFiles(objChild)
      Next
    End Sub

    ==========================================================

    Can anyone help me to adapt for the changes i want to implement ?

    Thanks in advance,

    Marex

    Thursday, January 23, 2014 10:59 AM

Answers

  • I think your expectations of free help in a user-to-user support forum may be a little unrealistic.

    This isn't a script on demand forum where people post a list of requirements and have other people write scripts for you (or completely rewrite/fix broken scripts).

    Bill

    Well, although you might be write, in no way i "demand" anything.

    As i've seen on other posts, i presented my doubts/difficulties, i showed what i did by myself and the results it had and i'm asking if anyone can help me with my problems, that's all.

    I think my post doesnt differ, in anything, from other posts of "free help" i've seen.

    Marex

    What you did for yourself is to copy a script from the Internet that seems to have nothing to do with what you are asking.

    Use the learning tools and try and write the scrip you are asking for.   Look in the Gallery for scripts that do nearly what you need.  A little testing and effort will get you closer.

    Start here: http://technet.microsoft.com/en-us/scriptcenter/dd772284

    All of the pieces you are asking for are demonstrated in the tutorials.

    When you get stuck on a specific item then post pack with a single question.  You are asking a smorgasbord of questions that amount to asking for a complete design and build.

    Your post is not a question but is a list of requirements that you want to see fulfilled.  Try asking a single question.


    ¯\_(ツ)_/¯

    Thursday, January 23, 2014 4:17 PM

All replies

  • What are you asking?  Saying "adapt for the changes i want " does not make much sense.  We cannot read you mind.


    ¯\_(ツ)_/¯

    Thursday, January 23, 2014 2:20 PM
  • What are you asking?  Saying "adapt for the changes i want " does not make much sense.  We cannot read you mind.


    ¯\_(ツ)_/¯

    Well, i said what i want to implement in the beginning of my post...and i'll quote:

    - Search a list of pre-determined computers and specific path (example: \\computer\c:\<random folder>\<random folder> for only *.pst files, if not, returns an information saying that it doesnt have any file present.

    - Export that list to excel by date created, date last modified, size, attributes and path

    Thursday, January 23, 2014 3:39 PM
  • I think your expectations of free help in a user-to-user support forum may be a little unrealistic.

    This isn't a script on demand forum where people post a list of requirements and have other people write scripts for you (or completely rewrite/fix broken scripts).

    Bill

    Thursday, January 23, 2014 4:03 PM
    Moderator
  • I think your expectations of free help in a user-to-user support forum may be a little unrealistic.

    This isn't a script on demand forum where people post a list of requirements and have other people write scripts for you (or completely rewrite/fix broken scripts).

    Bill

    Well, although you might be write, in no way i "demand" anything.

    As i've seen on other posts, i presented my doubts/difficulties, i showed what i did by myself and the results it had and i'm asking if anyone can help me with my problems, that's all.

    I think my post doesnt differ, in anything, from other posts of "free help" i've seen.

    Marex

    Thursday, January 23, 2014 4:09 PM
  • I think your expectations of free help in a user-to-user support forum may be a little unrealistic.

    This isn't a script on demand forum where people post a list of requirements and have other people write scripts for you (or completely rewrite/fix broken scripts).

    Bill

    Well, although you might be write, in no way i "demand" anything.

    As i've seen on other posts, i presented my doubts/difficulties, i showed what i did by myself and the results it had and i'm asking if anyone can help me with my problems, that's all.

    I think my post doesnt differ, in anything, from other posts of "free help" i've seen.

    Marex

    What you did for yourself is to copy a script from the Internet that seems to have nothing to do with what you are asking.

    Use the learning tools and try and write the scrip you are asking for.   Look in the Gallery for scripts that do nearly what you need.  A little testing and effort will get you closer.

    Start here: http://technet.microsoft.com/en-us/scriptcenter/dd772284

    All of the pieces you are asking for are demonstrated in the tutorials.

    When you get stuck on a specific item then post pack with a single question.  You are asking a smorgasbord of questions that amount to asking for a complete design and build.

    Your post is not a question but is a list of requirements that you want to see fulfilled.  Try asking a single question.


    ¯\_(ツ)_/¯

    Thursday, January 23, 2014 4:17 PM
  • Here is a starter: http://technet.microsoft.com/library/ee176995.aspx

    Start by learning how to read a file in a loop then look at the tutorial on how to work with files and folders.


    ¯\_(ツ)_/¯

    Thursday, January 23, 2014 4:20 PM