2 Replies Latest reply on Jun 6, 2017 9:30 AM by .-.--.--

    ViewLogic.Exec vs WScript.Shell


      What are the advantages/disadvantages of using ViewLogic.Exec vs WScript.Shell for executing shell commands? I have a lot of scripts that open a text file in Notepad or a spreadsheet in Excel so I'm wondering if there is a great advantage in using one or the other.



        • 1. Re: ViewLogic.Exec vs WScript.Shell

          The biggest difference is that Viewlogic.Exec exists on Linux, where WScript.Shell does not.


          If you only run on windows, and just use it to run graphical applications, there's probably no reason to switch to Viewlogic.Exec.


          But if you need it to run on Linux, or you need to run a program and capture the program output (stdout, stderr), then Viewlogic.Exec is the way to go.



          • 2. Re: ViewLogic.Exec vs WScript.Shell

            There is another significant difference.


            ViewLogic.Exec has a .WorkingDirectory property.  Its value can be set to an absolute or relative path within the current application.  Actually, its value can be set to any text string, including the famous illegal Windows filename characters (\ / : * ? " < > |), because the string is not immediately validated against the file system.  Hence, caveat user, although it only affects the associated shell, and not the application.  Also, its value ends when the current script ends.


            WScript.Shell has a .CurrentDirectory property.  Its value can also be set to an absolute or relative path within the current application, but it will be converted to an absolute path, and validated against the file system, thereby producing an error if it is improper.  In addition, its value does not end when the current script ends, because it actually changes the working directory of the application, which could potentially cause malfunction of any integrated system commands.  So, if you change this property, be sure to capture its original value, and reset it before exit (or error).  Definitely, caveat user.