Options

Read EventLog

NavStudentNavStudent Member Posts: 399
edited 2007-06-15 in NAV Tips & Tricks
Hello
I'm running an executable from navision that write messages in event log. I would like to use a standard automation to query theh eventlog for the message. Can someone point me to the right direction?
The com has to be standard so that I don't have to register it on every box.


Thank you.
my 2 cents

Comments

  • Options
    ara3nara3n Member Posts: 9,255
    Hello.
    Today is your lucky Day.

    Here is an example on how to do it. It uses windows host scrip.

    //look/query at event for the error.
         WindowShell.CurrentDirectory(ENVIRON('windir') + '\system32\');
         txtCommand := 'cscript eventquery.vbs /L Application /FI "Type eq Error" /V /r 1 /FO "LIST"';
         WSHExec := WindowShell.Exec(txtCommand);
         WSHTextStream := WSHExec.StdOut;
         //read till 15th line for error
         I := 0;
         WHILE (NOT WSHTextStream.AtEndOfStream) AND (I < 15) DO BEGIN
          txtMsg := WSHTextStream.ReadLine();
          I +=  1;
         END;
         ERROR(txtMsg);
    

    WindowShell is of type 'Windows Script Host Object Model'.WshShell
    WSHExec is of type 'Windows Script Host Object Model'.WshExec
    WSHTextStream is of type 'Windows Script Host Object Model'.TextStream

    You can find more info on this automation in the following link


    You can find more help http://www.mibuso.com/forum/viewtopic.php?t=12417&highlight=


    as far as eventquery.vbs is concerned and parameters that you can pass to it. you can look in the following link.

    http://technet.microsoft.com/en-us/library/bb490900.aspx

    the code above you can run from cmd prompt and you'll see the output.
    Navigate to c:\windows\system32\

    then paste this code
    cscript eventquery.vbs /L Application /FI "Type eq Error" /V /r 1 /FO "LIST"

    and run it'll you see the error.
    Good luck.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • Options
    krikikriki Member, Moderator Posts: 9,096
    [Topic moved from Navision forum to Navision Tips & Tricks forum]
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • Options
    NavStudentNavStudent Member Posts: 399
    wow great solution. Thank you for the solution. =D>
    my 2 cents
  • Options
    ara3nara3n Member Posts: 9,255
    You are welcome.

    It looks like this has been moved to tips and tricks. :)
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • Options
    krikikriki Member, Moderator Posts: 9,096
    ara3n wrote:
    You are welcome.

    It looks like this has been moved to tips and tricks. :)
    :roll:


    :D
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


Sign In or Register to comment.