Announcement

Collapse
No announcement yet.

Code Help

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Code Help

    Hello,

    I'm trying to read a text file and find a key word "Cleaned" and if that keyword is found, I want it to run a batch file. If the keyword is not found then exit the application. Having issues with the if then syntax.

    Any help would be great. Thanks


    [CODE][/
    binString = TextFile.ReadToString("C:\\ProgramData\\McAfee\\De sktopProtection\\OnDemandScanlog.txt");

    arg = Input.GetText("Input1")
    Where = String.Find(""..binString, ""..arg, 1, true)
    --Dialog.Message("Data found at file pos:", ""..Where)

    if arg == true then

    File.Open("AutoPlay\\Docs\\VirusLog.bat", "", SW_SHOWNORMAL);

    Application.Sleep(10000);

    File.Delete("C:\\ProgramData\\McAfee\\DesktopProte ction\\OnDemandScanlog.txt", false, false, false, nil);

    Application.Exit(0);

    elseif arg == false then

    Application.Exit(0);

    endCODE]

  • #2
    Your code is very wrong that is why, you get the text from a input box what would be a string format you check the string and store it in Where so you need to check if find found

    so
    if Where ~= -1 then
    do something
    else
    do something else
    end
    Plugins or Sources MokoX
    BunnyHop 2021 Here

    Comment


    • #3
      Thanks That worked!

      I do have another question. I'm trying to open a log file in APMS (File attached) to a paragraph. However, It only shows garbage... How can I convert this to a text file, so I can use the string.find command I tried renaming to txt and that did not working.

      Is it possible to have APMS open the file with notepad and save it with a different name?

      Thanks!
      Attached Files

      Comment


      • #4
        Originally posted by Widget View Post
        Thanks That worked!

        I do have another question. I'm trying to open a log file in APMS (File attached) to a paragraph. However, It only shows garbage... How can I convert this to a text file, so I can use the string.find command I tried renaming to txt and that did not working.

        Is it possible to have APMS open the file with notepad and save it with a different name?

        Thanks!
        Code:
        2015-04-09T13:04:34.656Z Service started - System Center Endpoint Protection (DDEFDD14-250E-4DC8-A0B3-9D667EC5D8EB)
        2015-04-09T13:04:35.765Z Version: Product 4.3.220.0 Service 4.3.220.0 Engine 1.1.11502.0 AS 1.195.2100.0 AV 1.195.2100.0
        2015-04-12T13:15:24.181Z Version: Product 4.3.220.0 Service 4.3.220.0 Engine 1.1.11502.0 AS 1.195.2967.0 AV 1.195.2967.0
        2015-04-17T12:51:52.071Z DETECTION SettingsModifier:Win32/PossibleHostsFileHijack file:C:\Users\poret_000\Desktop\hosts
        2015-04-17T12:56:22.982Z DETECTION SettingsModifier:Win32/PossibleHostsFileHijack file:C:\Windows\System32\drivers\etc\hosts
        2015-04-17T21:16:50.857Z Version: Product 4.3.220.0 Service 4.3.220.0 Engine 1.1.11502.0 AS 1.195.3623.0 AV 1.195.3623.0
        2015-04-20T14:17:21.124Z Service started - System Center Endpoint Protection (DDEFDD14-250E-4DC8-A0B3-9D667EC5D8EB)
        2015-04-20T14:17:22.249Z Version: Product 4.3.220.0 Service 4.3.220.0 Engine 1.1.11502.0 AS 1.195.3623.0 AV 1.195.3623.0
        2015-04-20T14:37:14.727Z Service started - System Center Endpoint Protection (DDEFDD14-250E-4DC8-A0B3-9D667EC5D8EB)
        2015-04-20T14:37:15.696Z Version: Product 4.3.220.0 Service 4.3.220.0 Engine 1.1.11502.0 AS 1.195.3623.0 AV 1.195.3623.0
        2015-04-20T15:53:24.117Z Service started - System Center Endpoint Protection (DDEFDD14-250E-4DC8-A0B3-9D667EC5D8EB)
        2015-04-20T15:53:25.101Z Version: Product 4.3.220.0 Service 4.3.220.0 Engine 1.1.11502.0 AS 1.195.3623.0 AV 1.195.3623.0
        2015-04-22T13:40:53.215Z Service started - System Center Endpoint Protection (DDEFDD14-250E-4DC8-A0B3-9D667EC5D8EB)
        2015-04-22T13:40:54.387Z Version: Product 4.3.220.0 Service 4.3.220.0 Engine 1.1.11502.0 AS 1.195.3623.0 AV 1.195.3623.0
        2015-04-24T13:26:46.934Z Service started - System Center Endpoint Protection (DDEFDD14-250E-4DC8-A0B3-9D667EC5D8EB)
        2015-04-24T13:26:48.137Z Version: Product 4.3.220.0 Service 4.3.220.0 Engine 1.1.11602.0 AS 1.197.343.0 AV 1.197.343.0
        2015-04-27T11:23:33.290Z Service started - System Center Endpoint Protection (DDEFDD14-250E-4DC8-A0B3-9D667EC5D8EB)
        2015-04-27T11:23:34.477Z Version: Product 4.3.220.0 Service 4.3.220.0 Engine 1.1.11602.0 AS 1.197.343.0 AV 1.197.343.0
        2015-04-29T03:34:14.141Z Version: Product 4.3.220.0 Service 4.3.220.0 Engine 1.1.11602.0 AS 1.197.874.0 AV 1.197.874.0
        the .log file is already a text file this is the basic details in the file.

        try TextFile.ReadToTable

        this will read each line to a table.
        Plugins or Sources MokoX
        BunnyHop 2021 Here

        Comment


        • #5
          Just being "already a text file" may not be enough. The log file is Unicode encoded, and Lua can work only with ANSI encoded files.

          The easiest approach for this is using the Unicode plugin and convert the file to ANSI during the import into AutoPlay Media Studio. Once this is done, you can display or work with the data.
          Code:
          [COLOR="#0000FF"]local[/COLOR] sFile [COLOR="#FF0000"]=[/COLOR] Unicode[COLOR="#FF0000"].[/COLOR]ReadToString([COLOR="#800080"]"AutoPlay[COLOR="#800080"]\\[/COLOR]Docs[COLOR="#800080"]\\[/COLOR]MPDetection.log"[/COLOR][COLOR="#FF0000"],[/COLOR] [COLOR="#800080"]"unicode"[/COLOR])[COLOR="#FF0000"];[/COLOR]
          Paragraph[COLOR="#FF0000"].[/COLOR]SetText([COLOR="#800080"]"Paragraph1"[/COLOR][COLOR="#FF0000"],[/COLOR] sFile)[COLOR="#FF0000"];[/COLOR]
          Click image for larger version

Name:	SCRN-2015-04-29-01.png
Views:	1
Size:	69.2 KB
ID:	284307
          Ulrich

          Comment


          • #6
            I tried as suggested using the below code. Paragraph is blank and no error... What did I miss.

            Code:
            text_contents = TextFile.ReadToTable("C:\\MPDetection.log");
            Paragraph.SetText("Paragraph1", "", text_contents)

            Comment


            • #7
              The plugin worked. Thanks!

              Comment


              • #8
                Originally posted by Widget View Post
                The plugin worked. Thanks!
                Because you can't just print a table like that, but if his plugin does the job no need for the more complex way.
                Plugins or Sources MokoX
                BunnyHop 2021 Here

                Comment


                • #9
                  Originally posted by Ulrich View Post
                  Just being "already a text file" may not be enough. The log file is Unicode encoded, and Lua can work only with ANSI encoded files.

                  The easiest approach for this is using the Unicode plugin and convert the file to ANSI during the import into AutoPlay Media Studio. Once this is done, you can display or work with the data.
                  Code:
                  [COLOR="#0000FF"]local[/COLOR] sFile [COLOR="#FF0000"]=[/COLOR] Unicode[COLOR="#FF0000"].[/COLOR]ReadToString([COLOR="#800080"]"AutoPlay[COLOR="#800080"]\\[/COLOR]Docs[COLOR="#800080"]\\[/COLOR]MPDetection.log"[/COLOR][COLOR="#FF0000"],[/COLOR] [COLOR="#800080"]"unicode"[/COLOR])[COLOR="#FF0000"];[/COLOR]
                  Paragraph[COLOR="#FF0000"].[/COLOR]SetText([COLOR="#800080"]"Paragraph1"[/COLOR][COLOR="#FF0000"],[/COLOR] sFile)[COLOR="#FF0000"];[/COLOR]
                  [ATTACH=CONFIG]12757[/ATTACH]
                  Ulrich
                  AMS does not handle Unicode, as most of AMS' functions interpret each null character as the end of string character. Lua does support binary data in strings, so Unicode can be properly manipulated in Lua and even be converted to ASCII. Lua in AMS still supports Unicode, can read unicode strings and can convert a simple unicode text to ascii.

                  Just some extra information for those who care.
                  Bas Groothedde
                  Imagine Programming :: Blog

                  AMS8 Plugins
                  IMXLH Compiler

                  Comment

                  Working...
                  X