Kaseya Community

Agent procedure to create time-stamped text file

This question is answered

Hello,


I have a procedure that is supposed to run a tracert (and gather other basic diagnostic info) if another ping test fails. I have the procedure working but I'd like to add the time that the tracert was run, down to the minute. I have this all working in a batch file, but trying to build a procedure and figure out what Kaseya is expecting is quite difficult -- such as realizing the open bracket used to output to a file is two >> rather than just one >. Below is what I have so far. Unfortunately, it is creating the text file with %runtime% in the file name instead of the actual format I have set, which is var_trace_YEAR_MONTH_DAY_HOUR_MINUTE.txt.

I am using the "executeShellCommand" statement for all the below lines:

line 1 = set runtime=%date:~10,4%_%date:~4,2%_%date:~7,2%_%TIME:~0,2%_%TIME:~3,2%

line 2 = ipconfig /all >>"c:\"var_trace_%runtime%.txt""

line 3 = tracert mail.mydomainname.com >>>>"c:\"var_trace_%runtime%.txt""

line 4 = systeminfo >>>>"c:\"var_trace_%runtime%.txt""

Any ideas anyone??

Verified Answer
  • Procedure BasicNetworkDiag.zip

    Each line is executed in its own separate shell instance so the runtime variable is not seen by the other shell commands.

    You can try Echo the time value to a text file and then use the Get Variable File Content to read the contents of the text file into a procedure variable instead.

    I have attached a working example of how you would script what you are asking for without the need of any clunky batch files.

All Replies
  • To me is sounds like the variables are not passing across the executeshellcommand.  I would toss the commands into a BAT file and run that way.

  • Just call the bat file from your kaseya script.

  • So does the bat file need to be stored on each computer where the procedure will be run? Or, is there a way to "store" it in Kaseya? Can you explain how to use a bat instead? Would I just use the same "executeShellCommand" statement and just have the following(?):

    @echo off

    c:\tracert.bat

    Thanks everyone!



    clarified
    [edited by: dborchert at 10:11 AM (GMT -8) on Nov 26, 2013]
  • Procedure BasicNetworkDiag.zip

    Each line is executed in its own separate shell instance so the runtime variable is not seen by the other shell commands.

    You can try Echo the time value to a text file and then use the Get Variable File Content to read the contents of the text file into a procedure variable instead.

    I have attached a working example of how you would script what you are asking for without the need of any clunky batch files.

  • Five stars for Mr. HardKnoX.