Sage 100

 View Only
Expand all | Collapse all

How do I run a windows batch file after a VI job f

  • 1.  How do I run a windows batch file after a VI job f

    Posted 11-03-2017 10:00
    How do I run a windows batch file after a VI job finishes? I know how to trigger Perform Logic, but not a regular .bat file.


  • 2.  RE: How do I run a windows batch file after a VI job f

    Posted 11-03-2017 11:08
    This might work. I have done something similar in the past. If your VI job is ""VIWI11"" then: Download and install a 30 trial of PVXPLUS. http://www.pvxplus.com/pgsrvr.pvp?pg=dl_pxp9 Backup then copy VIWI11 from MAS90\VI to C:\Program Files (x86)\PVX Plus Technologies\PVX Plus VX.XX. Execute PVXPLUS.exe From the PVX prompt type Load ""VIWI11"" Modify the code to add (I think) the INVOKE directive. You can verify the syntax by looking at the doc: http://manual.pvxplus.com/ Copy VIWI11 back to the MAS90\VI folder


  • 3.  RE: How do I run a windows batch file after a VI job f

    Posted 11-03-2017 11:29
    Thanks @DougHiggs . That seems like a bit much for what I'm trying to achieve (and I'm guessing a recompile of the VI job would require me to redo the pxplus edit). I have a multiple step import process (to be run hourly) and the next step after the VI job (a SQL command... Premium customer) can't be run before the import is completed. It should only take a couple minutes for the import, but if the SQL script runs before it's done, that would be bad. What I'd like is a safety net... not running the SQL command until the VI is finished. Is there a simple way to do this? I was thinking a batch file could create a txt file, and a loop in the scheduled process could just wait for that text file to appear. Any other ideas would be appreciated.


  • 4.  RE: How do I run a windows batch file after a VI job f

    Posted 11-03-2017 11:45
    Chain another VI job that imports one record to an unused table (maybe a UDT if VI can import into those) and attach a trigger to that table that runs your SQL script on INSERT?


  • 5.  RE: How do I run a windows batch file after a VI job f

    Posted 11-03-2017 11:53
    @PhilMcIntosh ... that might work. I'd have to find a way to reset the table, or make sure I'm updating the row by using a date / time as the imported value, to ensure the UDS gets triggered.


  • 6.  RE: How do I run a windows batch file after a VI job f

    Posted 11-03-2017 12:16
    You can put a trigger on the table in SQL itself. Normally triggers do some validation or cascading (like a trigger on an order line table that updates the inventory onOrder qty when a new record is inserted) of the record being inserted, but there is nothing to say it has to. It can run whatever SQL commands are in your script. See http://www.tech-recipes.com/rx/41414/sql-server-coding-the-after-insert-trigger-in-sql-server/ for a simple example.


  • 7.  RE: How do I run a windows batch file after a VI job f

    Posted 11-03-2017 12:44
    Couldn't the whole thing be in a single batch file (executed by Task Scheduler), including the V/I import?


  • 8.  RE: How do I run a windows batch file after a VI job f

    Posted 11-03-2017 12:44
    Thanks again @PhilMcIntosh . I understand the power of SQL triggers but haven't worked with them much. I might go with a UDS, simply because we are more familiar with them. Plus, I can then keep all the main logic for the process in one place to make things easier to manage / troubleshoot.


  • 9.  RE: How do I run a windows batch file after a VI job f

    Posted 11-03-2017 12:45
    That is what I am trying to do, but I need to ensure that the VI job has actually finished before running the next step.


  • 10.  RE: How do I run a windows batch file after a VI job f

    Posted 11-03-2017 12:48
    Does a preceding START /WAIT in front of the V/I line work? https://technet.microsoft.com/en-us/library/bb491005.aspx


  • 11.  RE: How do I run a windows batch file after a VI job f

    Posted 11-03-2017 12:49
    Use the TIMEOUT command http://www.robvanderwoude.com/wait.php


  • 12.  RE: How do I run a windows batch file after a VI job f

    Posted 11-03-2017 12:50
    I'm not sure if the V/I line would set ERRORLEVELs, so you wouldn't be 100% sure if the import job was actually successful or not.


  • 13.  RE: How do I run a windows batch file after a VI job f

    Posted 11-03-2017 12:54
    Click on Perform button and choose Job Completion. Instead of typing path to Perform Logic program, press F1. I don't quite remember the syntax but you can execute o/s commands by preceding the line with a * *c:\MyPath\RunMe.bat If running Adv /Premium you may (or may not) have to do it as *[wdx] so the path is relative to the client. Try it both ways.


  • 14.  RE: How do I run a windows batch file after a VI job f

    Posted 11-03-2017 13:11
    It was in the help files?!?! Thanks @AlnoorCassim !!!


  • 15.  RE: How do I run a windows batch file after a VI job f

    Posted 11-03-2017 14:01
    That's a great tool for the tool bag. Thanks @AlnoorCassim