Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Microsoft VBScript runtime error while running it from batch exe file  (Read 7658 times)

0 Members and 1 Guest are viewing this topic.

Yogesh123

    Topic Starter


    Beginner

    I have created a batch script .exe  file,
    in which i am calling below ProcessStartTime.vbs file to capture the start date & time of EXCEL.EXE process,
    ----
    call ProcessStartTime.vbs
    ----
    and i have scheduled that batch script .exe file in the scheduled task,
    but while running the .exe file below error message gets popped-up on the screen,
    Please help to resolve the same,

    error as :- Windows Script host
    script: c:\aeclm\ProcessStartTime.vbs
    Line: 7
    Char: 1
    Error: Permission Denied
    code: 800A0046
    Source:Microsoft VBScript runtime error


    ----------ProcessStartTime.vbs code-------------------
    Const ForReading    = 1
    Const ForWriting    = 2
    Const ForAppending  = 8

    Set objFSO = CreateObject("Scripting.FileSystemObject")

    Set objLogFile = objFSO.OpenTextFile("C:\aeclm\Process_list.txt", _
        ForWriting, True)

    'objLogFile.Write _
    '   ("Process Name,Start Time,Process ID")

    'objLogFile.Writeline

    strComputer = "."

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


    Set colProcessStartTrace = objWmiService.ExecQuery _
        ("Select * From Win32_Process")


    For Each objProcess in colProcessStartTrace
       
        if(objProcess.Name = "EXCEL.EXE")then
           objLogFile.Write(objProcess.Name) & ","
           objLogFile.Write(objProcess.CreationDate) & ","
           objLogFile.Write(objProcess.ProcessId)
           objLogFile.writeline
       end if
    Next
       

    objLogFile.Close
    --------------------------------------------

    Salmon Trout

    • Guest
    You don't have write permission in C:\aeclm. You need to obtain this.