{"id":7733,"date":"2023-06-27T13:00:02","date_gmt":"2023-06-27T13:00:02","guid":{"rendered":"https:\/\/www.samlogic.net\/blog\/?p=7733"},"modified":"2023-06-28T09:19:19","modified_gmt":"2023-06-28T09:19:19","slug":"how-to-run-a-program-or-open-a-document-via-script","status":"publish","type":"post","link":"https:\/\/www.samlogic.net\/blog\/2023\/06\/how-to-run-a-program-or-open-a-document-via-script\/","title":{"rendered":"How to run a program or open a document via script"},"content":{"rendered":"<p><img decoding=\"async\" class=\"alignright\" src=\"https:\/\/www.samlogic.net\/pad\/icons\/visual_installer.gif\" border=\"0\" alt=\"\">In the previous two blog posts we described how to <a href=\"https:\/\/www.samlogic.net\/blog\/2023\/06\/how-to-run-a-program-after-installation\/\">run a program<\/a> or <a href=\"https:\/\/www.samlogic.net\/blog\/2023\/06\/how-to-show-a-document-after-an-installation\/\">show a document<\/a> after an installation, when running a setup package created with <a href=\"https:\/\/www.samlogic.net\/visual-installer\/visual-installer.htm\" rel=\"noopener\" target=\"_blank\">Visual Installer<\/a>. It is also possible to run a program or open a document via Visual Installer\u00b4s <a href=\"https:\/\/www.samlogic.net\/visual-installer\/tips\/tips-pages\/visual-installer-scripting-language\/visual-installer-scripting-language.htm\" rel=\"noopener\" target=\"_blank\">script language<\/a>.<\/p>\n<p>One benefit of using script for running a program or opening a document is that you can use a conditional check before you run\/open the file. You can for example run different versions of a program depending on which operating system the installation is run in. For example:<\/p>\n<div style=\"background-color: #f4f4f4; padding: 8px;\">\n<span style=\"color: #008000;\">\/\/ Run only in Windows 10<\/span><br \/>\n<span style=\"color: #000080;\">IF<\/span> OS=WIN10<br \/>\n<span style=\"color: #000080;\">\u00a0 RUN<\/span> <span style=\"color: #800000;\">%DESTDIR<\/span>\\MyWin10App.exe<br \/>\n<span style=\"color: #000080;\">END IF<\/span><br \/>\n<span style=\"color: #000080;\"> &nbsp; <\/span><br \/>\n<span style=\"color: #008000;\">\/\/ Run only in Windows 11<\/span><br \/>\n<span style=\"color: #000080;\">IF<\/span> OS=WIN11<br \/>\n<span style=\"color: #000080;\">\u00a0 RUN<\/span> <span style=\"color: #800000;\">%DESTDIR<\/span>\\MyWin11App.exe<br \/>\n<span style=\"color: #000080;\">END IF<\/span>\n<\/div>\n<p>&nbsp;&nbsp;<br \/>\nIn the same way you can open and show a particular document based on a condition. For example:<\/p>\n<div style=\"background-color: #f4f4f4; padding: 8px;\">\n<span style=\"color: #008000;\">\/\/ Open and show only in Windows 10<\/span><br \/>\n<span style=\"color: #000080;\">IF<\/span> OS=WIN10<br \/>\n<span style=\"color: #000080;\">\u00a0 SHOW_AFTER<\/span> <span style=\"color: #800000;\">%DESTDIR<\/span>\\For_Win10_Users.pdf<br \/>\n<span style=\"color: #000080;\">END IF<\/span><br \/>\n<span style=\"color: #000080;\"> &nbsp; <\/span><br \/>\n<span style=\"color: #008000;\">\/\/ Open and show only in Windows 11<\/span><br \/>\n<span style=\"color: #000080;\">IF<\/span> OS=WIN11<br \/>\n<span style=\"color: #000080;\">\u00a0 SHOW_AFTER<\/span> <span style=\"color: #800000;\">%DESTDIR<\/span>\\For_Win11_Users.pdf<br \/>\n<span style=\"color: #000080;\">END IF<\/span>\n<\/div>\n<p>&nbsp;&nbsp;<br \/>\nThe RUN command above (example 1) is executed immediately and the SHOW_AFTER command above (example 2) is executed when the installation is completed. Read more below.<br \/>\n&nbsp;&nbsp;<br \/>\n<span style=\"color: #000080; font-size: 18px;\"><strong>Script commands in Visual Installer that run programs<\/strong><\/span><br \/>\nThese three script commands can be used to run programs during an installation:<\/p>\n<div style=\"background-color: #f4f4f4; padding: 8px;\">\n<strong>RUN<\/strong> : Runs a program.<br \/>\n<strong>XRUN<\/strong> : Runs a program &#8211; with additional options.<br \/>\n<strong>RUN_AFTER<\/strong> : Runs a program &#8211; when the installation is completed.\n<\/div>\n<p>&nbsp;&nbsp;<br \/>\n<span style=\"color: #000080; font-size: 18px;\"><strong>Script commands in Visual Installer that open documents<\/strong><\/span><br \/>\nThese two script commands can be used to open documents during an installation:<\/p>\n<div style=\"background-color: #f4f4f4; padding: 8px;\">\n<strong>SHOW<\/strong> : Opens a document.<br \/>\n<strong>SHOW_AFTER<\/strong> :  Opens a document &#8211; when the installation is completed.\n<\/div>\n<p>&nbsp;&nbsp;<br \/>\nThe RUN, XRUN and SHOW commands are executed immediately, when the script line is executed, but the RUN_AFTER and SHOW_AFTER commands delays it execution till the installation is completed and the last setup dialog box has been closed.<\/p>\n<p><em>The RUN_AFTER and SHOW_AFTER commands are new commands that were included in version 12.0.10 of Visual Installer (<a href=\"https:\/\/www.samlogic.net\/blog\/2023\/06\/an-update-of-visual-installer-2022-is-now-available\/\">read more<\/a>).<\/em><\/p>\n<p><strong>See also<\/strong><br \/>\n<strong><span style=\"color: #ff0000;\">&gt;<\/span><\/strong> <a href=\"https:\/\/www.samlogic.net\/blog\/2023\/06\/how-to-run-a-program-after-installation\/\">How to run a program after an installation<\/a><br \/>\n<strong><span style=\"color: #ff0000;\">&gt;<\/span><\/strong> <a href=\"https:\/\/www.samlogic.net\/blog\/2023\/06\/how-to-show-a-document-after-an-installation\/\">How to show a document after an installation<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In the previous two blog posts we described how to run a program or show a document after an installation, when running a setup package created with Visual Installer. It is also possible to run a program or open a document via Visual Installer\u00b4s script language. One benefit of using script for running a program &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.samlogic.net\/blog\/2023\/06\/how-to-run-a-program-or-open-a-document-via-script\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How to run a program or open a document via script&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[10,15],"tags":[],"_links":{"self":[{"href":"https:\/\/www.samlogic.net\/blog\/wp-json\/wp\/v2\/posts\/7733"}],"collection":[{"href":"https:\/\/www.samlogic.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.samlogic.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.samlogic.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.samlogic.net\/blog\/wp-json\/wp\/v2\/comments?post=7733"}],"version-history":[{"count":44,"href":"https:\/\/www.samlogic.net\/blog\/wp-json\/wp\/v2\/posts\/7733\/revisions"}],"predecessor-version":[{"id":7778,"href":"https:\/\/www.samlogic.net\/blog\/wp-json\/wp\/v2\/posts\/7733\/revisions\/7778"}],"wp:attachment":[{"href":"https:\/\/www.samlogic.net\/blog\/wp-json\/wp\/v2\/media?parent=7733"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.samlogic.net\/blog\/wp-json\/wp\/v2\/categories?post=7733"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.samlogic.net\/blog\/wp-json\/wp\/v2\/tags?post=7733"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}