{"id":1240,"date":"2015-05-14T21:39:04","date_gmt":"2015-05-14T11:39:04","guid":{"rendered":"http:\/\/ntsblog.homedev.com.au\/?p=1240"},"modified":"2015-06-18T01:42:54","modified_gmt":"2015-06-17T15:42:54","slug":"self-extracting-archive-runs-setup-exe-7zip-sfx-switch","status":"publish","type":"post","link":"https:\/\/ntsblog.homedev.com.au\/index.php\/2015\/05\/14\/self-extracting-archive-runs-setup-exe-7zip-sfx-switch\/","title":{"rendered":"How to make a self extracting archive that runs your setup.exe with 7zip -sfx switch"},"content":{"rendered":"<div id=\"ntsbl-2029947120\" class=\"ntsbl-before-content ntsbl-entity-placement\"><script async src=\"\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js?client=ca-pub-6288941070289539\" crossorigin=\"anonymous\"><\/script><ins class=\"adsbygoogle\" style=\"display:inline-block;width:728px;height:90px;\" \ndata-ad-client=\"ca-pub-6288941070289539\" \ndata-ad-slot=\"9356781486\"><\/ins> \n<script> \n(adsbygoogle = window.adsbygoogle || []).push({}); \n<\/script>\n<\/div><h2>The scenario<\/h2>\n<p>When you use the default Microsoft Visual Studio Installer (yes, it is back as an extension for VS 2013 &#8211; <a href=\"https:\/\/visualstudiogallery.msdn.microsoft.com\/9abe329c-9bba-44a1-be59-0fbf6151054d\" target=\"_blank\">Visual studio Installer Projects Extension<\/a>), the output are two files:<\/p>\n<ol>\n<li>installer.msi &#8211; the .msi installation file<\/li>\n<li>setup.exe &#8211; which is the bootstrap that does your pre-requisite checks<\/li>\n<\/ol>\n<p>So you want to provide a download for your product from your website as a single file. <\/p>\n<p>Some possible options include:<\/p>\n<ol>\n<li>Zip the two files &#8211; the user has to download a zip, extract the zip and run the setup.exe<\/li>\n<li>Just provide the msi file, but this by passes the pre-requisite checks which is not ideal; or<\/li>\n<li>Create a self extracting archive that runs, extracts the software and then calls the setup.exe <\/li>\n<\/ol>\n<p>The self extracting archive option seems the best.<\/p>\n<h2>The problem<\/h2>\n<p>I wanted to use 7Zip to create the self extracting archive but I could not seem to find a simple guide that explained exactly how to do it.<\/p>\n<p>I have finally worked it out and below are some detailed instructions.<\/p>\n<h2>How to make a self extracting archive that launches your installer after extraction<\/h2>\n<p>It is actually quite simple to do if you follow these easy steps.<\/p>\n<h3>Step 1 &#8211; Setup your installation folder<\/h3>\n<p>To make this easy create a folder c:\\Install. This is where we will copy all the required files.<\/p>\n<h3>Step 2 &#8211; 7Zip your installers<\/h3>\n<ol>\n<li>Go to the folder that has your msi and your setup.exe<\/li>\n<li>Select both the .msi and the setup.exe<\/li>\n<li>Right-Click and choose 7Zip &#8211;> &#8220;Add to Archive&#8221;<\/li>\n<li>Name your archive &#8220;Installer.7z&#8221; (or a name of your choice)<\/li>\n<li>Click Ok<\/li>\n<li>You should now have &#8220;Installer.7z&#8221;. <\/li>\n<li>Copy this .7z file to your c:\\Install directory<\/li>\n<\/ol>\n<h3>Step 3 &#8211; Get the 7z-Extra sfx extension module<\/h3>\n<p>You need to download the 7z-Extra.<\/p>\n<ol>\n<li>Follow this link to go to <a href=\"http:\/\/www.7-zip.org\/download.html\" target=\"_blank\">7zip download<\/a>. <\/li>\n<li>You need to download the 9.20 version (as @ May-2015) as the beta does not contain the correct files.<\/li>\n<li> A <a href=\"http:\/\/www.7-zip.org\/a\/7z920_extra.7z\" target=\"_blank\">direct download<\/a> link. <\/li>\n<li>Extract the 7zip extra files<\/li>\n<li>Copy the file &#8220;7zS.sfx&#8221; to c:\\Install<\/li>\n<\/ol>\n<h3>Step 4 &#8211; Setup your config.txt<\/h3>\n<p>I would recommend using NotePad++ to edit this text file as you will need to encode in UTF-8, the following instructions are using notepad++.<\/p>\n<ol>\n<li>Using windows explorer go to c:\\Install<\/li>\n<li>right-click and choose &#8220;New Text File&#8221; and name it config.txt<\/li>\n<li>right-click and choose &#8220;Edit with NotePad++<\/li>\n<li>Click the &#8220;Encoding Menu&#8221; and choose &#8220;Encode in UTF-8&#8221;<\/li>\n<li>Enter something like this:<br \/>\n[csharp]<br \/>\n;!@Install@!UTF-8!<br \/>\nTitle=&quot;SOFTWARE v1.0.0.0&quot;<br \/>\nBeginPrompt=&quot;Do you want to install SOFTWARE v1.0.0.0?&quot;<br \/>\nRunProgram=&quot;setup.exe&quot;<br \/>\n;!@InstallEnd@!<br \/>\n[\/csharp]\n<\/li>\n<\/ol>\n<p>Edit this replacing [SOFTWARE v1.0.0.0] with your product name.<br \/>\nNotes on the parameters and options for the setup file are <a href=\"http:\/\/sevenzip.osdn.jp\/chm\/cmdline\/switches\/sfx.htm\" target=\"_blank\">here<\/a><\/p>\n<h3>CheckPoint<\/h3>\n<p>You should now have a folder &#8220;c:\\Install&#8221; with the following 3 files:<\/p>\n<ol>\n<li>Installer.7z<\/li>\n<li>7zS.sfx<\/li>\n<li>config.txt<\/li>\n<\/ol>\n<h3>Step 5 &#8211; Create the archive<\/h3>\n<p>These instructions I found on the web but nowhere did it explain any of the 4 steps above.<\/p>\n<ol>\n<li>Open a cmd window, Window + R &#8211;> cmd &#8211;> press enter<\/li>\n<li>In the command window type the following<br \/>\n[csharp]<br \/>\ncd \\<br \/>\ncd Install<br \/>\ncopy \/b 7zS.sfx + config.txt + Installer.7z MyInstaller.exe<br \/>\n[\/csharp]\n<\/li>\n<li>Look in c:\\Install and you will now see you have a MyInstaller.exe<\/li>\n<p>You are finished<\/p>\n<h3>Run the installer<\/h3>\n<p>Double click on MyInstaller.exe and it will prompt with your message. Click OK and the setup.exe will run.<\/p>\n<p>Everything is easy&#8230; once you know how. \ud83d\ude42<\/p>\n<h3>P.S. Note on Automation<\/h3>\n<p>Now that you have this working in your c:\\Install directory I would create an &#8220;Install.bat&#8221; file and put the copy script in it.<\/p>\n<p>[csharp]<br \/>\ncopy \/b 7zS.sfx + config.txt + Installer.7z MyInstaller.exe<br \/>\n[\/csharp]<\/p>\n<p>Now you can just edit and run the Install.bat every time you need to rebuild a new version of you deployment package.<\/p>\n<h3>P.P.S. super user<\/h3>\n<p>If you got here from the super user article, perhaps you would like to vote my answer up \ud83d\ude42<br \/>\nThanks<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The scenario When you use the default Microsoft Visual Studio Installer (yes, it is back as an extension for VS 2013 &#8211; Visual studio Installer [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[29],"tags":[],"class_list":["post-1240","post","type-post","status-publish","format-standard","hentry","category-scripts"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/ntsblog.homedev.com.au\/index.php\/wp-json\/wp\/v2\/posts\/1240","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ntsblog.homedev.com.au\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ntsblog.homedev.com.au\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ntsblog.homedev.com.au\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ntsblog.homedev.com.au\/index.php\/wp-json\/wp\/v2\/comments?post=1240"}],"version-history":[{"count":0,"href":"https:\/\/ntsblog.homedev.com.au\/index.php\/wp-json\/wp\/v2\/posts\/1240\/revisions"}],"wp:attachment":[{"href":"https:\/\/ntsblog.homedev.com.au\/index.php\/wp-json\/wp\/v2\/media?parent=1240"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ntsblog.homedev.com.au\/index.php\/wp-json\/wp\/v2\/categories?post=1240"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ntsblog.homedev.com.au\/index.php\/wp-json\/wp\/v2\/tags?post=1240"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}