| |
butcha33
Posts: 6
Score: 0
Joined: 8/15/2008
Status: offline
|
Hi, i am having problem with this script. It works perfect on my local machine and all remote machines but only on the C drive! If i try to search for a *.mp3 on any other partition other than C it fails with this error message. New to scripting so your help will be appreciated cheers Butcha Line 45 Char 1 The Remote Procedure Call Failed 800706BE Source (null) 'on error resume next servername = InputBox ("Enter Machine Name" & (Chr(13) & Chr(10)) & "Example: dc-live-it028 ", "My Audit by Shieraz B") If servername = "" then WScript.quit end if drive = InputBox ("Enter Drive Letter" & (Chr(13) & Chr(10)) & "Example: C / D (Case sensitive)", "My Audit by Shieraz B") If drive = "" then WScript.quit end if strExtension = InputBox ("Enter File Extension" & (Chr(13) & Chr(10)) & "Example: mp3", "My Audit by Shieraz B") If strExtension = "" then WScript.quit end if strDrive = drive & ":" Set objExcel = CreateObject("Excel.Application") objExcel.Visible = True objExcel.Workbooks.Add x = 2 objExcel.Cells(1, 1).Value = "File Name" objExcel.Cells(1, 2).Value = "File Size" objExcel.Cells(1, 3).Value = "Path (" & servername & " " & strDrive & ")" objExcel.Cells(1, 4).Value = "Creation Date" objExcel.Cells(1, 5).Value = "Last Accessed" objExcel.Range("A1:E1").Select objExcel.Selection.Interior.ColorIndex = 15 objExcel.Selection.Font.Bold = True objExcel.Cells.EntireColumn.AutoFit Set objWMIService = GetObject("winmgmts:\\" & servername & "\root\cimv2") Set colFiles = objWMIService.ExecQuery _ ("Select * from CIM_DataFile Where Drive = '" & strDrive & "' And Extension = '" & strExtension & "'") For Each objItem in colFiles objExcel.Cells(x, 1).Value = objItem.FileName objExcel.Cells(x, 2).Value = FormatNumber(objItem.FileSize/1024/1024,1) & " MB" objExcel.Cells(x, 3).Value = objItem.Path objExcel.Cells(x, 4).Value = ConvWbemTime(objItem.CreationDate) objExcel.Cells(x, 5).Value = ConvWbemTime(objItem.LastAccessed) x = x + 1 Next Function ConvWbemTime(IntervalFormat) sMonth = mid(IntervalFormat,5,2) sDay = mid(IntervalFormat,7,2) sYear = mid(IntervalFormat,1,4) sHour = mid(IntervalFormat,9,2) sMinutes = mid(IntervalFormat,11,2) sSeconds = mid(IntervalFormat,13,2) ConvWbemTime = sMonth & "-" & sDay & "-" & sYear & " " & sHour & ":" & sMinutes & ":" & sSeconds End Function objExcel.Range("A1:E1").Select objExcel.Selection.Interior.ColorIndex = 15 objExcel.Selection.Font.Bold = True objExcel.Cells.EntireColumn.AutoFit Set objSheet = objExcel.ActiveWorkbook.Worksheets(1) Set objRange = objExcel.Range("A2") objRange.Sort objRange,1,,,,,,1 objExcel.Cells(x, 1).Font.Bold = TRUE objExcel.Cells(x, 1).Font.Size = 10 objExcel.Cells(x, 1).Value = "Search Completed, Save the spreadsheet!" 'MsgBox "Done"
|
|