/build/static/layout/Breadcrumb_cap_w.png

Scripting Question


Finding PST and creating a report for both x86 and x64

06/01/2017 699 views

tQyAlr.jpeg

Kace script


Hello,

 I have a VBS script that will create a folder on the c drive to place the results of the search. However its not working in windows x64. I want it to run in both OSs. Also if there is a easier way to create the report.

I run the script to place the results in the folder, then run force update to pull the TXT file , then run a report .


PST VBS

strComputer = "."
on error resume next
set wshnetwork=createobject("wscript.network")
scomputername=wshnetwork.computername
set wshnetwork=nothing
Const OverwriteExisting = True

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

Set colFiles = objWMIService.ExecQuery _
    ("Select * from CIM_DataFile Where Extension = 'pst' AND (Drive = 'C:' OR Drive = 'H:' or drive'w:')")

If colFiles.Count = 0 Then
    Wscript.Quit
End If


Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.CreateFolder("C:\kbox")
Set objTextFile = objFSO.CreateTextFile("c:\kbox\pstfiles.txt" , True)

For Each objFile in colFiles
    objTextFile.Write(objFile.Drive & objFile.Path & "")
    objTextFile.Write(objFile.FileName & "." & objFile.Extension & ", Size ")
    objTextFile.Write(objFile.FileSize /1024 & "kb" & vbCrLf)
Next

objTextFile.Close

 


7 Comments   [ + ] Show comments

Comments

  • I think your issue is actually due to not running script in the right architecture. Since it works in 32 bit and not in 64 bit, you will need to run the 32bit cscript bit from here:
    C:\windows\sysWOW64\cscript.exe

    Try running this batch in your remediation step:
    @echo off
    If exist C:\windows\sysWOW64\cscript.exe (
    Echo 64 bit OS... Going to Success
    Exit /b 0
    ) else (
    Echo 32 bit OS... Going to Failure
    Exit /b 1
    )

    Success:
    Run from here C:\windows\sysWOW64\cscript.exe

    Failure:
    Run From here C:\windows\system32\cscript.exe
  • Script comes back with no errors. but has this under a user results
    Running as: afisher
    File does not exist: c:\kbox\pstfiles.txt
    Creating process returned non-zero: C:\Windows\System32\cscript.exe C:\ProgramData\Dell\KACE\user\tmp\5r5fu9iw\packages\kbots\924/FindOutlookpst.vbs: (0) The operation completed successfully.
    Error Code: 0
    Status Code: 1
  • It's not putting the VBS in the package area. so the program can't run.
  • Some 64bit OS has the package will other don't. Don't understand why same agent version
  • Try changing the forward slash to a backslash: /FindOutlookpst.vbs
    • its that way. it works on some 64 but not others.
    • its that way. it works on some 64 but not others.
  • How about powershell?
    get-childitem C:,H:,W: *.PST -recurse -erroraction SilentlyContinue | Select fullname, @{n='Size_MB';e={ "{00:N2}" -f (($_.length) / 1MB) }} | Format-Table -HideTableHeaders |Out-File c:\kbox\pstfiles.txt -force
    • what if the c:\box is not there getting an error. can you create the file and folder
  • You could put this before it:
    If (-not(test-path C:\kbox)) {mkdir C:\kbox}

Be the first to answer this question

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

View more:

Share

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ