Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Untitled.vbs(28, 1) VBScript runtime error

Options
  • 18-02-2005 6:39pm
    #1
    Registered Users Posts: 68 ✭✭


    Hi Folks
    I bought a book there a while ago "Windows Admin Scripting 2nd ED" little Black Book. It seem to be a dream reference material but I' run into a problem with one of the scripts. Deleting all tmp files from a system. Basicly it deletes tmp files and creates a log in a spreadsheet. But it bombs out on me with the following error:
    Microsoft (R) Windows Script Host Version 5.6
    Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.

    C:\Program Files\SAPIEN\PrimalScript\Untitled.vbs(28, 1) Microsoft VBScript runtime error: Unknown runtime error

    Exit code: 0 , 0000h


    It doesn't seem to like line 28. Can someone please cast a fresh eye over this. Apart from being sick looking at it I'm a relative newbie and could missing something obvious. the system im running the script on is XP Pro with Office 2002 installed. For anyone with the book see page 104. Thanks

    '==========================================================================
    '
    ' VBScript Source File -- Created with SAPIEN Technologies PrimalScript 3.1
    '
    ' NAME:
    '
    ' AUTHOR: ,
    ' DATE : 18/02/2005
    '
    ' COMMENT:
    '
    '==========================================================================


    Set FSO = CreateObject("Scripting.FileSystemObject")
    Set ExcelApp = CreateObject("Excel.Application")
    Row = 1
    Coloum = 1
    ExcelApp.Workbooks.Add
    ExcelApp.Visible = True

    sDIR = "c:\"
    sEXT = "TMP"
    sTITLE = "Deleting Files"

    ExcelApp.Caption =sTITLE
    ExcelApp.Range("A1").Select
    ExcelApp.Selection.Font.Bold = True
    ExcelApp.Cells(Row,Column).value = "Deletion Log:" & sEXT & " fILES"
    ***ln 28*** :eek:
    Row = Row + 1
    Set objDIR = GetFolder(sDIR)
    GoSubFolders objDIR
    ExcelApp.Selection.Font.Bold = True
    Row = Row + 1
    ExcelApp.Cells(Row,Column).value = "**end of log**"

    Sub MainSub (objDIR)
    For each efile in objDIR.Files
    fEXT = FSO.GetExtensionName(efile.Path)
    If LCase(fEXT) = LCase (sEXT) Then
    DelFile efile
    End If
    Next
    End Sub

    Sub GoSubFolders (objDIR)
    If objDIR <> "\System Volume Information" Then
    MainSub objDIR
    For each eFolder in objDIR.Subfolders
    GoSubFolders eFolder
    Next
    End If
    End Sub

    Sub DelFile(sFILE)
    On Error Resume Next
    FSO.DeleteFile sFILE, True
    If Err.Number <> 0 Then
    ExcelApp.Cells(Row,Column).Value = "ERROR DELETING: " & sFILE
    Else
    ExcelApp.Cells(Row,Column).Value = "DELETED: " & sFILE
    End If
    Row = Row + 1
    End Sub

    Function GetFolder(sFOLDER)
    On Error Resume Next
    Set GetFolder = FSO.GetFolder(sFOLDER)
    If Err.Number <> 0 Then
    Wscript.Echo "Error connecting to folder: " & sFOLDER & VBlf & "[" & Err.Number & "] " & Err.Description
    Wscript.Quit Err.Number
    End If
    End Function


Comments

  • Registered Users Posts: 431 ✭✭plenderj


    Try this instead and see if it makes any difference...
    ExcelApp.Cells(0, 0).value = "Deletion Log:" & sEXT & " fILES"


  • Registered Users Posts: 68 ✭✭alancool


    No joy I just get the same runtime error, thanks though


  • Registered Users Posts: 68 ✭✭alancool


    oh oh bit of a type-o in the spelling of a variable "coloum" ;)


Advertisement