{"id":5258,"date":"2017-10-11T14:00:02","date_gmt":"2017-10-11T13:00:02","guid":{"rendered":"http:\/\/www.samlogic.net\/blog\/?p=5258"},"modified":"2019-07-07T17:23:54","modified_gmt":"2019-07-07T17:23:54","slug":"using-the-log-function-in-visual-installers-script-language","status":"publish","type":"post","link":"https:\/\/www.samlogic.net\/blog\/2017\/10\/using-the-log-function-in-visual-installers-script-language\/","title":{"rendered":"Using the log function in Visual Installer&#8217;s script language"},"content":{"rendered":"<p><img decoding=\"async\" class=\"alignright\" src=\"https:\/\/www.samlogic.net\/pad\/icons\/visual_installer.gif\" border=\"0\" alt=\"\">When using the <a href=\"https:\/\/www.samlogic.net\/visual-installer\/tips\/tips-pages\/visual-installer-scripting-language\/visual-installer-scripting-language.htm\" target=\"_blank\" rel=\"noopener noreferrer\">script language<\/a> in <a href=\"https:\/\/www.samlogic.net\/visual-installer\/visual-installer.htm\" target=\"_blank\" rel=\"noopener noreferrer\">Visual Installer<\/a>, it may sometimes be useful to see in detail what happen when the script lines are executed. To get detailed information about the execution of script commands, you can activate a log function in Visual Installer&#8217;s script language. When the log is activated, detailed information about every script line that is executed are stored in a log file. Here you can see the contents of the parameters that are passed to the script commands and see the return value (for example error codes) of every command. If you use <a href=\"https:\/\/www.samlogic.net\/blog\/2016\/07\/variables-in-visual-installer\/\">variables<\/a> in the script (for example <strong>%DESTDIR<\/strong>) you can see their actual values.<\/p>\n<p><strong>How to activate the log function<\/strong><br \/>\nTo activate the log function, you can use the <strong>USELOG<\/strong> script command. To enable the log, enter the following in the beginning of your script code:<\/p>\n<p><strong>USELOG 1<\/strong><\/p>\n<p>As default, the log file is stored in the main destination folder of the installation (the folder path that is stored in the <strong>%DESTDIR<\/strong> variable) but you can also specify your own folder for the log file via parameter 2. For example:<\/p>\n<p><strong>USELOG 1, C:\\MyLogFolder<\/strong><\/p>\n<p>To turn off the log, somewhere in the script, you can enter the following:<\/p>\n<p><strong>USELOG 0<\/strong><\/p>\n<p>If you want to log all lines in the script, you don&#8217;t need to turn off the log at the end. It will be turned off automatically after the last executed script line.<\/p>\n<p>In the picture below, you can see an example of how the <strong>USELOG<\/strong> command can be used:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.samlogic.net\/blog\/images\/product-visual-installer\/vi-script-uselog--cropped.png\" alt=\"USELOG\" border=\"0\"><\/p>\n<p>And below is an example of how the log file may look like:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.samlogic.net\/blog\/images\/product-visual-installer\/vi-script-log--ok.png\" alt=\"Log (OK)\" border=\"0\"><\/p>\n<p>If a script command succeeds, it returns OK. Otherwise it returns ERROR and an error code. Below is an example of how the log file may look like if an error occurs:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.samlogic.net\/blog\/images\/product-visual-installer\/vi-script-log--error.png\" alt=\"Log (Error)\" border=\"0\"><\/p>\n<p>Most error codes can be found on this web page at Microsoft&#8217;s web site:<\/p>\n<p><strong><span style=\"color: #ff0000;\">&gt;<\/span><\/strong> <a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/windows\/desktop\/ms681382(v=vs.85).aspx\" target=\"_blank\" rel=\"noopener noreferrer\">Windows Dev Center: System Error Codes (0-499)<\/a><\/p>\n<p>Some common error codes are:<\/p>\n<p><strong>2<\/strong> : File not found!<br \/>\n<strong>3<\/strong> : Path not found!<br \/>\n<strong>5<\/strong> : Access denied!<br \/>\n<strong>183<\/strong> : File already exists!<\/p>\n<p><strong>Filenames<\/strong><br \/>\nThe filename of the log file is <strong>Vinstall-Script&#8211;Before.log<\/strong> if the script lines are executed in the <strong>Before installation<\/strong> tab in the <strong>Execute script commands<\/strong> window in Visual Installer, and the filename is <strong>Vinstall-Script&#8211;After.log<\/strong> if the script lines are executed in the <strong>After installation<\/strong> tab in the same window. The filenames can not be changed, but you can change the folder where the log files are stored (as described above).<\/p>\n<p><strong>See also<\/strong><br \/>\n<strong><span style=\"color: #ff0000;\">&gt;<\/span><\/strong> <a href=\"https:\/\/www.samlogic.net\/visual-installer\/tips\/tips-pages\/visual-installer-scripting-language\/visual-installer-scripting-language.htm\" target=\"_blank\" rel=\"noopener noreferrer\">Visual Installer&#8217;s Scripting Language<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>When using the script language in Visual Installer, it may sometimes be useful to see in detail what happen when the script lines are executed. To get detailed information about the execution of script commands, you can activate a log function in Visual Installer&#8217;s script language. When the log is activated, detailed information about every &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.samlogic.net\/blog\/2017\/10\/using-the-log-function-in-visual-installers-script-language\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Using the log function in Visual Installer&#8217;s script language&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[10,15],"tags":[],"_links":{"self":[{"href":"https:\/\/www.samlogic.net\/blog\/wp-json\/wp\/v2\/posts\/5258"}],"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=5258"}],"version-history":[{"count":1,"href":"https:\/\/www.samlogic.net\/blog\/wp-json\/wp\/v2\/posts\/5258\/revisions"}],"predecessor-version":[{"id":6012,"href":"https:\/\/www.samlogic.net\/blog\/wp-json\/wp\/v2\/posts\/5258\/revisions\/6012"}],"wp:attachment":[{"href":"https:\/\/www.samlogic.net\/blog\/wp-json\/wp\/v2\/media?parent=5258"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.samlogic.net\/blog\/wp-json\/wp\/v2\/categories?post=5258"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.samlogic.net\/blog\/wp-json\/wp\/v2\/tags?post=5258"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}