{"id":7473,"date":"2021-10-24T15:19:02","date_gmt":"2021-10-24T15:19:02","guid":{"rendered":"https:\/\/max-drake.cc\/?p=7473"},"modified":"2021-10-24T19:15:02","modified_gmt":"2021-10-24T19:15:02","slug":"setting-up-install-files-to-share-for-prototyping-with-security","status":"publish","type":"post","link":"https:\/\/max-drake.cc\/?p=7473","title":{"rendered":"Setting up install files to share for prototyping with security"},"content":{"rendered":"\n<p>Following on from <a href=\"https:\/\/max-drake.cc\/?p=7456\"><strong>Compile a program for install for distribution<\/strong><\/a> article.<\/p>\n\n\n\n<p>I&#8217;m thinking about doing some paid work, so I want to be able to send prototype scripts to people to use, but not the full version, or rather a version that will run for a while and then stop. <\/p>\n\n\n\n<p>That way the customer can test it out and see whether it meets their need, but not take it and run without paying if it does. <\/p>\n\n\n\n<p>After playing with a couple of installer setup programs (see other post) I&#8217;m satisfied, at the moment with NSIS. So this post is about using that. <\/p>\n\n\n\n<p>It seems to require a rethink on how I write files and also think about using files. <\/p>\n\n\n\n<p>Whatever procedures I setup at this point, I do not want to mess with the OS registry at this point. So do it all with files. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Processes for short active scripts<\/h2>\n\n\n\n<p>There are a couple of methods that I&#8217;ve thought of (as in re-inventing the wheel) and they are ,<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li> via count, you can run so many times, then it stops<\/li><li>a specific duration (trial period).<\/li><\/ol>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"516\" height=\"744\" data-src=\"https:\/\/max-drake.cc\/wp-content\/uploads\/2021\/10\/2021-10-24-08_21_01-Bubbl.us-Cultivation-\u2014-Mozilla-Firefox.jpg\" alt=\"\" class=\"wp-image-7479 lazyload\" data-srcset=\"https:\/\/max-drake.cc\/wp-content\/uploads\/2021\/10\/2021-10-24-08_21_01-Bubbl.us-Cultivation-\u2014-Mozilla-Firefox.jpg 516w, https:\/\/max-drake.cc\/wp-content\/uploads\/2021\/10\/2021-10-24-08_21_01-Bubbl.us-Cultivation-\u2014-Mozilla-Firefox-208x300.jpg 208w, https:\/\/max-drake.cc\/wp-content\/uploads\/2021\/10\/2021-10-24-08_21_01-Bubbl.us-Cultivation-\u2014-Mozilla-Firefox-50x72.jpg 50w, https:\/\/max-drake.cc\/wp-content\/uploads\/2021\/10\/2021-10-24-08_21_01-Bubbl.us-Cultivation-\u2014-Mozilla-Firefox-35x50.jpg 35w, https:\/\/max-drake.cc\/wp-content\/uploads\/2021\/10\/2021-10-24-08_21_01-Bubbl.us-Cultivation-\u2014-Mozilla-Firefox-100x144.jpg 100w, https:\/\/max-drake.cc\/wp-content\/uploads\/2021\/10\/2021-10-24-08_21_01-Bubbl.us-Cultivation-\u2014-Mozilla-Firefox-69x100.jpg 69w, https:\/\/max-drake.cc\/wp-content\/uploads\/2021\/10\/2021-10-24-08_21_01-Bubbl.us-Cultivation-\u2014-Mozilla-Firefox-444x640.jpg 444w\" data-sizes=\"(max-width: 516px) 100vw, 516px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 516px; --smush-placeholder-aspect-ratio: 516\/744;\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">File Structure<\/h2>\n\n\n\n<p>For the file structure, you are giving them an .EXE compiled file (so they can&#8217;t EASILY look at the script- AHK scripts viewable) and whatever added support files that script requires, license, readMe, Library Files and importantly .ini files and write-to files. <\/p>\n\n\n\n<p>The .EXE file is compiled, so can&#8217;t change, so any changes- eg Start\/End dates has to be put into a writable file such as an ini file. So if you do a FROM DATE (first time the program runs, eg INSTALL DATE) to an END DATE eg 30 days after the  FROM DATE, then you need to be able to write these date somewhere and a .ini file is a good place to do so. <\/p>\n\n\n\n<p>The same goes for COUNT. If you preset the .ini file to Count 5 and count down, or set as 0 and count up. <\/p>\n\n\n\n<p>So, main file .EXE and a counter with an IF \/Then statement of some kind in the .EXE . If the COUNT less than 5 then DO &#8230;. The main script, if NOT then Quit with a Message Box saying no more playing, program has expired. <\/p>\n\n\n\n<p>File Locations &amp; where to define their path<\/p>\n\n\n\n<p>I think, if you fix the path in the compiled .EXE file then you have to re-set each time. When designing the program you know what files you want, but you may change your mind later on where you want to locate them. <\/p>\n\n\n\n<p>In fact, there is the opportunity to allow for the client to say where they want to keep &amp; name the files that they use. I may look at that later, for the moment I want to define the paths. <\/p>\n\n\n\n<p>So, better to have the file paths in the ini file and get the .EXE to pull them in to read them, this will work with all the other files apart from the ini file as its got to be found by the .EXE file, actually you can create another ini file, but this will then give away the location of the hidden ini file unless you do jiggery pokery and only give half the name and allow for a concatenation inside the compiled file. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">File locations  &amp; first iteration<\/h2>\n\n\n\n<p>So you don&#8217;t want your .ini file in the same folder as your .EXE file, otherwise they can just reset the count. Then they can use the program regardless. <\/p>\n\n\n\n<p>An aside Note: <em>The main .EXE has to be able to find the .ini file, otherwise it NEEDS TO BREAK. So if the directories are not setup right and the .EXE can&#8217;t check the .ini file then it shouldn&#8217;t be able to work at all. This would stop someone moving all the files somewhere else to run them. <\/em><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"673\" data-src=\"https:\/\/max-drake.cc\/wp-content\/uploads\/2021\/10\/2021-10-24-08_09_24-Bubbl.us-Cultivation-\u2014-Mozilla-Firefox-1-1024x673.jpg\" alt=\"\" class=\"wp-image-7478 lazyload\" data-srcset=\"https:\/\/max-drake.cc\/wp-content\/uploads\/2021\/10\/2021-10-24-08_09_24-Bubbl.us-Cultivation-\u2014-Mozilla-Firefox-1-1024x673.jpg 1024w, https:\/\/max-drake.cc\/wp-content\/uploads\/2021\/10\/2021-10-24-08_09_24-Bubbl.us-Cultivation-\u2014-Mozilla-Firefox-1-300x197.jpg 300w, https:\/\/max-drake.cc\/wp-content\/uploads\/2021\/10\/2021-10-24-08_09_24-Bubbl.us-Cultivation-\u2014-Mozilla-Firefox-1-768x505.jpg 768w, https:\/\/max-drake.cc\/wp-content\/uploads\/2021\/10\/2021-10-24-08_09_24-Bubbl.us-Cultivation-\u2014-Mozilla-Firefox-1-50x33.jpg 50w, https:\/\/max-drake.cc\/wp-content\/uploads\/2021\/10\/2021-10-24-08_09_24-Bubbl.us-Cultivation-\u2014-Mozilla-Firefox-1-76x50.jpg 76w, https:\/\/max-drake.cc\/wp-content\/uploads\/2021\/10\/2021-10-24-08_09_24-Bubbl.us-Cultivation-\u2014-Mozilla-Firefox-1-100x66.jpg 100w, https:\/\/max-drake.cc\/wp-content\/uploads\/2021\/10\/2021-10-24-08_09_24-Bubbl.us-Cultivation-\u2014-Mozilla-Firefox-1-152x100.jpg 152w, https:\/\/max-drake.cc\/wp-content\/uploads\/2021\/10\/2021-10-24-08_09_24-Bubbl.us-Cultivation-\u2014-Mozilla-Firefox-1-974x640.jpg 974w, https:\/\/max-drake.cc\/wp-content\/uploads\/2021\/10\/2021-10-24-08_09_24-Bubbl.us-Cultivation-\u2014-Mozilla-Firefox-1-640x421.jpg 640w, https:\/\/max-drake.cc\/wp-content\/uploads\/2021\/10\/2021-10-24-08_09_24-Bubbl.us-Cultivation-\u2014-Mozilla-Firefox-1-1169x768.jpg 1169w, https:\/\/max-drake.cc\/wp-content\/uploads\/2021\/10\/2021-10-24-08_09_24-Bubbl.us-Cultivation-\u2014-Mozilla-Firefox-1.jpg 1473w\" data-sizes=\"(max-width: 1024px) 100vw, 1024px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1024px; --smush-placeholder-aspect-ratio: 1024\/673;\" \/><\/figure>\n\n\n\n<p>So you want to put your .ini file somewhere a bit obscure, like in the AppData folder, that seems to be the programmers common place that people hide their files. As the AppData folder is a hidden folder you do need know its there to go looking for it. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Install Program<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">First Install <\/h3>\n\n\n\n<p>On first install the programs (using NSIS)  all go to <strong>C:\\Program Files (x86)\\<\/strong> and because this is a program folder they don&#8217;t like you writing to it unless you have Admin permission. So it makes sense not to put files that need to be written to in this directory. <\/p>\n\n\n\n<p>Now, if you have a file that you need to write to, for say, Time Capture or FileSaveLaunch, then the .TXT or .CSV file needs to be in a place that is :<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Accessible by users, if they need to copy\/edit that file <\/li><li>In a writable place such as C:\\users\\%A_User%\\Documents or C:\\users\\%A_User%\\Downloads, so you need to make sure that its in the current users directory so easily found. <\/li><li>Set the ini file such that it can&#8217;t be overwritten on an update. This stops the file from starting anew at a new install. Otherwise you just reinstall and the file starts afresh. So new program working on each new install. <\/li><\/ol>\n\n\n\n<p>So, in your compiled .EXE file, sitting in  <strong>C:\\Program Files (x86)\\<\/strong>   you need to make sure that the paths to its files are correct and working. <\/p>\n\n\n\n<p>This means allowing for a File location at the top of the ..to be compiled file and then using a variable in the code below for that location, this makes it easy to relocate files you are reading or writing to. <\/p>\n\n\n\n<p>In the install file you need to be able to create new directories in different places<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"932\" height=\"1024\" data-src=\"https:\/\/max-drake.cc\/wp-content\/uploads\/2021\/10\/2021-10-24-09_13_13-Bubbl.us-Cultivation-\u2014-Mozilla-Firefox-932x1024.jpg\" alt=\"\" class=\"wp-image-7480 lazyload\" data-srcset=\"https:\/\/max-drake.cc\/wp-content\/uploads\/2021\/10\/2021-10-24-09_13_13-Bubbl.us-Cultivation-\u2014-Mozilla-Firefox-932x1024.jpg 932w, https:\/\/max-drake.cc\/wp-content\/uploads\/2021\/10\/2021-10-24-09_13_13-Bubbl.us-Cultivation-\u2014-Mozilla-Firefox-273x300.jpg 273w, https:\/\/max-drake.cc\/wp-content\/uploads\/2021\/10\/2021-10-24-09_13_13-Bubbl.us-Cultivation-\u2014-Mozilla-Firefox-768x843.jpg 768w, https:\/\/max-drake.cc\/wp-content\/uploads\/2021\/10\/2021-10-24-09_13_13-Bubbl.us-Cultivation-\u2014-Mozilla-Firefox-50x55.jpg 50w, https:\/\/max-drake.cc\/wp-content\/uploads\/2021\/10\/2021-10-24-09_13_13-Bubbl.us-Cultivation-\u2014-Mozilla-Firefox-46x50.jpg 46w, https:\/\/max-drake.cc\/wp-content\/uploads\/2021\/10\/2021-10-24-09_13_13-Bubbl.us-Cultivation-\u2014-Mozilla-Firefox-100x110.jpg 100w, https:\/\/max-drake.cc\/wp-content\/uploads\/2021\/10\/2021-10-24-09_13_13-Bubbl.us-Cultivation-\u2014-Mozilla-Firefox-91x100.jpg 91w, https:\/\/max-drake.cc\/wp-content\/uploads\/2021\/10\/2021-10-24-09_13_13-Bubbl.us-Cultivation-\u2014-Mozilla-Firefox-583x640.jpg 583w, https:\/\/max-drake.cc\/wp-content\/uploads\/2021\/10\/2021-10-24-09_13_13-Bubbl.us-Cultivation-\u2014-Mozilla-Firefox-640x703.jpg 640w, https:\/\/max-drake.cc\/wp-content\/uploads\/2021\/10\/2021-10-24-09_13_13-Bubbl.us-Cultivation-\u2014-Mozilla-Firefox-699x768.jpg 699w, https:\/\/max-drake.cc\/wp-content\/uploads\/2021\/10\/2021-10-24-09_13_13-Bubbl.us-Cultivation-\u2014-Mozilla-Firefox.jpg 957w\" data-sizes=\"(max-width: 932px) 100vw, 932px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 932px; --smush-placeholder-aspect-ratio: 932\/1024;\" \/><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\">Uninstall script in the First install build<\/h4>\n\n\n\n<p>You need to allow for both the write to file &amp; the ini file <strong>not to be uninstalled<\/strong> when looking to uninstall the program, this allows you to keep data and also remember, in the ini file that the timer\/counter has gone past its date\/count<\/p>\n\n\n\n<p>If you delete the ini fil then re-installing will overwrite\/create anew so that you can use the same setup to start again. That is why its important that 1\/ you do not delete the ini file and that you don&#8217;t allow overwrite if you try and install again. <\/p>\n\n\n\n<h3 class=\"wp-block-heading\">2nd Install\/update<\/h3>\n\n\n\n<p>Some situations that need to be managed:<\/p>\n\n\n\n<p>1.<strong> Client tries reinstalling existing install setup file.<\/strong><\/p>\n\n\n\n<p>Directly reinstalling the original setup file to overwrite the previous install. <\/p>\n\n\n\n<p>Need to block overwrite of .ini &amp; any data files- in NSIS you need to :<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>SetOverwrite off\nFile \"Time-Capture_File_HotKeys.ini\"<\/code><\/pre>\n\n\n\n<p>2. <strong>Clients program expired without testing. Too busy, or not enough attempts. <\/strong><\/p>\n\n\n\n<p>In this scenario you want to be able to delete the existing .ini file and maybe even reload most of the program files (so updating looks obvious). So that you can reset clock\/count in ini file, and possibly send an adjusted ini file<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>create a new script installer that will delete old ini file and write a new one. <\/li><li>Keep existing data .txt files held elsewhere (ie ignore them)<\/li><\/ul>\n\n\n\n<p>The<span style=\"background-color:#fcb900\" class=\"background-color\"> problem with this one , unless you can make them only run it once, or give them a key that can only be used once, they can keep on using it to update the program so it will always run. <\/span><\/p>\n\n\n\n<p>One thought is a method of running this <span style=\"background-color:#f78da7\" class=\"background-color\">is to install a dud file somewhere , and if that exists then don&#8217;t overwrite .ini file, I&#8217;m not sure you can do that with the install. Needs a bit of research<\/span><\/p>\n\n\n\n<p>Another  thought is to have 3 or 4 .ini files, all with their Timers set at 0. The main program reads an ini file, say Count.ini  in the main Folder, it has a single number in it, 1, 2, 3 ,4  and depending on number is which hidden  ini file it reads.  So you send someone an update install script that updates the Count.ini file. When running the program the Count.ini file points to which hidden ini file to read.  A little crude, but it will work.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"957\" height=\"1024\" data-src=\"https:\/\/max-drake.cc\/wp-content\/uploads\/2021\/10\/2021-10-24-09_13_25-Bubbl.us-Cultivation-\u2014-Mozilla-Firefox-957x1024.jpg\" alt=\"\" class=\"wp-image-7481 lazyload\" data-srcset=\"https:\/\/max-drake.cc\/wp-content\/uploads\/2021\/10\/2021-10-24-09_13_25-Bubbl.us-Cultivation-\u2014-Mozilla-Firefox-957x1024.jpg 957w, https:\/\/max-drake.cc\/wp-content\/uploads\/2021\/10\/2021-10-24-09_13_25-Bubbl.us-Cultivation-\u2014-Mozilla-Firefox-280x300.jpg 280w, https:\/\/max-drake.cc\/wp-content\/uploads\/2021\/10\/2021-10-24-09_13_25-Bubbl.us-Cultivation-\u2014-Mozilla-Firefox-768x822.jpg 768w, https:\/\/max-drake.cc\/wp-content\/uploads\/2021\/10\/2021-10-24-09_13_25-Bubbl.us-Cultivation-\u2014-Mozilla-Firefox-50x54.jpg 50w, https:\/\/max-drake.cc\/wp-content\/uploads\/2021\/10\/2021-10-24-09_13_25-Bubbl.us-Cultivation-\u2014-Mozilla-Firefox-47x50.jpg 47w, https:\/\/max-drake.cc\/wp-content\/uploads\/2021\/10\/2021-10-24-09_13_25-Bubbl.us-Cultivation-\u2014-Mozilla-Firefox-100x107.jpg 100w, https:\/\/max-drake.cc\/wp-content\/uploads\/2021\/10\/2021-10-24-09_13_25-Bubbl.us-Cultivation-\u2014-Mozilla-Firefox-93x100.jpg 93w, https:\/\/max-drake.cc\/wp-content\/uploads\/2021\/10\/2021-10-24-09_13_25-Bubbl.us-Cultivation-\u2014-Mozilla-Firefox-598x640.jpg 598w, https:\/\/max-drake.cc\/wp-content\/uploads\/2021\/10\/2021-10-24-09_13_25-Bubbl.us-Cultivation-\u2014-Mozilla-Firefox-640x685.jpg 640w, https:\/\/max-drake.cc\/wp-content\/uploads\/2021\/10\/2021-10-24-09_13_25-Bubbl.us-Cultivation-\u2014-Mozilla-Firefox-718x768.jpg 718w, https:\/\/max-drake.cc\/wp-content\/uploads\/2021\/10\/2021-10-24-09_13_25-Bubbl.us-Cultivation-\u2014-Mozilla-Firefox.jpg 971w\" data-sizes=\"(max-width: 957px) 100vw, 957px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 957px; --smush-placeholder-aspect-ratio: 957\/1024;\" \/><\/figure>\n\n\n\n<p>3. <strong>You&#8217;ve updated the file for changes to program and you want to re-set timer\/count on ini file so they can test the new program<\/strong><\/p>\n\n\n\n<p>In this scenario you have updated code in main file, so you can create a new version and also create a different .ini and .txt files that you can send data to, keeping them in the same folders as the original  .ini and .txt files just with a version update. <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"927\" height=\"1024\" data-src=\"https:\/\/max-drake.cc\/wp-content\/uploads\/2021\/10\/2021-10-24-09_13_38-Bubbl.us-Cultivation-\u2014-Mozilla-Firefox-927x1024.jpg\" alt=\"\" class=\"wp-image-7482 lazyload\" data-srcset=\"https:\/\/max-drake.cc\/wp-content\/uploads\/2021\/10\/2021-10-24-09_13_38-Bubbl.us-Cultivation-\u2014-Mozilla-Firefox-927x1024.jpg 927w, https:\/\/max-drake.cc\/wp-content\/uploads\/2021\/10\/2021-10-24-09_13_38-Bubbl.us-Cultivation-\u2014-Mozilla-Firefox-272x300.jpg 272w, https:\/\/max-drake.cc\/wp-content\/uploads\/2021\/10\/2021-10-24-09_13_38-Bubbl.us-Cultivation-\u2014-Mozilla-Firefox-768x848.jpg 768w, https:\/\/max-drake.cc\/wp-content\/uploads\/2021\/10\/2021-10-24-09_13_38-Bubbl.us-Cultivation-\u2014-Mozilla-Firefox-50x55.jpg 50w, https:\/\/max-drake.cc\/wp-content\/uploads\/2021\/10\/2021-10-24-09_13_38-Bubbl.us-Cultivation-\u2014-Mozilla-Firefox-45x50.jpg 45w, https:\/\/max-drake.cc\/wp-content\/uploads\/2021\/10\/2021-10-24-09_13_38-Bubbl.us-Cultivation-\u2014-Mozilla-Firefox-100x110.jpg 100w, https:\/\/max-drake.cc\/wp-content\/uploads\/2021\/10\/2021-10-24-09_13_38-Bubbl.us-Cultivation-\u2014-Mozilla-Firefox-91x100.jpg 91w, https:\/\/max-drake.cc\/wp-content\/uploads\/2021\/10\/2021-10-24-09_13_38-Bubbl.us-Cultivation-\u2014-Mozilla-Firefox-579x640.jpg 579w, https:\/\/max-drake.cc\/wp-content\/uploads\/2021\/10\/2021-10-24-09_13_38-Bubbl.us-Cultivation-\u2014-Mozilla-Firefox-640x707.jpg 640w, https:\/\/max-drake.cc\/wp-content\/uploads\/2021\/10\/2021-10-24-09_13_38-Bubbl.us-Cultivation-\u2014-Mozilla-Firefox-695x768.jpg 695w, https:\/\/max-drake.cc\/wp-content\/uploads\/2021\/10\/2021-10-24-09_13_38-Bubbl.us-Cultivation-\u2014-Mozilla-Firefox.jpg 937w\" data-sizes=\"(max-width: 927px) 100vw, 927px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 927px; --smush-placeholder-aspect-ratio: 927\/1024;\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Scripts <\/h2>\n\n\n\n<ol class=\"wp-block-list\"><li>ShareFiles.ahk<\/li><\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>\/*\nShareFilesTest.ahk\nThis is a setup test for sharing files with others that will run for a specific period then stop\n\nThe setup is planned to allow others to test the compiled code for X number of runs then it stops working\n\n\n*\/\n;-----------------------Setup -----------------------------\n#NoEnv\n#SingleInstance, Force\nSetWorkingDir %A_ScriptDir%\n;-----------------------Include libraries -----------------------------\n#Include %A_ScriptDir%\\Notify.ahk\n\n;-----------------------Files &amp; Locations -----------------------------\n;CountIni has a single number, showing which ini file to be used. Defaults to 1 (the first file)\n;If client wants to run more of said program- send updated CountIni file with say 2 in it and \n;it will open the next sharefile.ini where counter starts back at 0. \nCountIni = ShareFileInf.ini \n\nIniRead, FileCount, %CountIni%, fileNum, FileCount\n\n;location of ini files\nIniFile = %A_AppData%\\MSys\\ShareFile%FileCount%.ini \n;The one below for testing if working \n;IniFile = C:\\Users\\%A_UserName%\\Downloads\\AHK-Working\\ShareFilesScript\\ShareFile.ini\n\n\n;get location of text file m, define as FileList\nIniRead, FileListDir, %IniFile%,FileLoc, FileListDir\n\nFileList= C:\\Users\\%A_UserName%\\%FileListDir%\n\nMsgBox, %FileList%  ; this is just to check that %A_UserName% is working correctly and plointing to the correct file. \n;------------------GLOBAL VARIABLES ----------------------\n\n;------These for Notify popup class-----------------\nText:= \"Share Files Started\"\nBackground=0x456789 ; a bluey color \nColor=0xFFFFFF ; white;\nTitle = \tSHARE FILES ;This is my TITLE\nTitleFont=\"Tahoma\"\nTitleColor= 0xFFFFFF ; white\nTitleSize=20\nSize=12 ;text height\nTime= 3000 ;3000\nIcon =145 ;297or145  tick,132 \"x\", 278 blue circle exclamation , 234 orange triangle exclamation; 220 no way,211 question in blue circle\nIconSize =30\n\n\n;------------------INITIATE INSTANCE OF NOTIFY ----------------------\nNotify:=Notify()\n;------------------NOTIFY POPUP  STARTING THE PROGRAM ----------------------\nNotify().AddWindow(Text,{Size:Size,Icon:Icon \",\" Ico,IconSize:IconSize,Title:Title,TitleColor:TitleColor,TitleFont:TitleFont,TitleSize:TitleSize,Background:Background,Color:Color,Time:Time}) ;Flash:1000,\n\n\nFileRead, Text4Message, %FileList%\n\n;------------------ PROGRAM STARTS----------------------\n;make sure path to &amp; name of  .ini file set \n\n;------------------ Read INI file for Count &amp; MaxNumber----------------------\nIniRead, Countx, %IniFile%,Counter, counter1\n;Test check count\nIniRead, MaxRun, %IniFile%, MaxCount, MaxRun\nMsgBox, %Countx% of total %MaxRun%  of %FileCount%   ; for display you need the %% signs either side v\n\nIf (Countx&lt;=MaxRun) { ; for function you DO NOT need the %% signs either side\n\n\/*\nTHIS IS WHERE YOU PUT PROGRAM CODE\nBetween brackets \n*\/\n\n    MsgBox, , Share Files Message Box, %Text4Message%`n If %Countx% less than %MaxRun% `nprogram will run `nEnjoy    ;Welcome to the %Countx% of %MaxRun%, after which program stops \n    Countx+=1 ; for function you DO NOT need the %% signs either side\n    IniWrite, %Countx%, %IniFile%, Counter, counter1\n     ExitApp\n\n\n\n\n    }else{\n\/*\nTHIS IS WHERE YOU PUT EXIT MESSAGE WHEN PROGRAM TO STOP\nBetween brackets \n*\/\n\n\n    MsgBox, , CLOSE Share Files Message Box,  %Text4Message% `nIf %Countx% bigger than %MaxRun% `nthe program stops working `nContact `nEnquiries@blah.blah     ;You are on %Countx% of %MaxRun% so program won't run `n contact provider at `nEnquiries@blah.blah\n    ExitApp\n    }<\/code><\/pre>\n\n\n\n<p>2. ShareFile.ini<\/p>\n\n\n\n\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;Counter]\ncounter1=0\n&#91;MaxCount]\nMaxRun = 4\n&#91;FileLoc]\n;FileList= C:\\Users\\%A_UserName%\\Documents\\ShareFile\\ShareFile.txt \n; DraxList= C:\\Users\\%A_UserName%\\\n;Note, rest of path setup in main script as it doesn't like %% coming from this file\nFileListDir= Documents\\ShareFile\\ShareFile.txt\n<\/code><\/pre>\n\n\n\n<p>3. NSIS install Script   .nsi  (in HS NIS Edit program)<\/p>\n\n\n\n<p>Note- I&#8217;ve commented out all the items to do with modifying Windows registry . I wanted a simple install.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>; Script generated by the HM NIS Edit Script Wizard.\n\/*\nThis is 1st Install Script\nIt installs main program in C:\/Program Files (+86)\/ShareFiles\nIt installs ini in Current User\/ AppData\nIt installs .txt in Current User\/ Documents\/ShareFiles\n\nini &amp; txt files not to be deleted on uninistall\nini &amp; txt files not to be overwritten if 1\/ Reinstall program\n\nMax Drake\nSunday 24 October 2021\n*\/\n\n; HM NIS Edit Wizard helper defines\n!define PRODUCT_NAME \"ShareFiles\"\n!define PRODUCT_VERSION \"1.0\"\n!define PRODUCT_PUBLISHER \"Drax\"\n!define PRODUCT_WEB_SITE \"https:\/\/max-drake.cc\"\n;!define PRODUCT_DIR_REGKEY \"Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\ShareFiles.exe\"\n;!define PRODUCT_UNINST_KEY \"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\${PRODUCT_NAME}\"\n;!define PRODUCT_UNINST_ROOT_KEY \"HKLM\"\n;!define PRODUCT_STARTMENU_REGVAL \"NSIS:StartMenuDir\"\n\n; MUI 1.67 compatible ------\n!include \"MUI.nsh\"\n\n; MUI Settings\n!define MUI_ABORTWARNING\n!define MUI_ICON \"${NSISDIR}\\Contrib\\Graphics\\Icons\\modern-install.ico\"\n!define MUI_UNICON \"${NSISDIR}\\Contrib\\Graphics\\Icons\\modern-uninstall.ico\"\n\n; Welcome page\n!insertmacro MUI_PAGE_WELCOME\n; License page\n!insertmacro MUI_PAGE_LICENSE \"..\\..\\Licence\\Licence-MD.txt\"\n; Directory page\n!insertmacro MUI_PAGE_DIRECTORY\n; Start menu page\nvar ICONS_GROUP\n!define MUI_STARTMENUPAGE_NODISABLE\n!define MUI_STARTMENUPAGE_DEFAULTFOLDER \"ShareFiles\"\n\/*\n!define MUI_STARTMENUPAGE_REGISTRY_ROOT \"${PRODUCT_UNINST_ROOT_KEY}\"\n!define MUI_STARTMENUPAGE_REGISTRY_KEY \"${PRODUCT_UNINST_KEY}\"\n!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME \"${PRODUCT_STARTMENU_REGVAL}\"\n*\/\n!insertmacro MUI_PAGE_STARTMENU Application $ICONS_GROUP\n; Instfiles page\n!insertmacro MUI_PAGE_INSTFILES\n; Finish page\n!define MUI_FINISHPAGE_RUN \"$INSTDIR\\ShareFiles.exe\"\n!define MUI_FINISHPAGE_SHOWREADME \"$INSTDIR\\ReadMe.rtf\"\n!insertmacro MUI_PAGE_FINISH\n\n; Uninstaller pages\n!insertmacro MUI_UNPAGE_INSTFILES\n\n; Language files\n!insertmacro MUI_LANGUAGE \"English\"\n\n; MUI end ------\n\nName \"${PRODUCT_NAME} ${PRODUCT_VERSION}\"\nOutFile \"..\\Builds\\ShareFiles_V1.1_20211025.exe\"\nInstallDir \"$PROGRAMFILES\\ShareFiles\"\n;InstallDirRegKey HKLM \"${PRODUCT_DIR_REGKEY}\" \"\"\nShowInstDetails show\nShowUnInstDetails show\n\nSection \"Prog Files\" SEC01\n  SetOutPath \"$INSTDIR\"\n  SetOverwrite on\n  File \"..\\Files\\ShareFiles.exe\"\n  File \"..\\Files\\share.jpg\"\n  File \"..\\Files\\share.ico\"\n  File \"..\\Files\\ReadMe.rtf\"\n  File \"..\\Files\\Notify.ahk\"\n  File \"..\\Files\\launch.ico\"\n  File \"..\\Files\\ShareFileInf.ini\"\n\n; Shortcuts\n  !insertmacro MUI_STARTMENU_WRITE_BEGIN Application\n  CreateDirectory \"$SMPROGRAMS\\$ICONS_GROUP\"\n  CreateShortCut \"$SMPROGRAMS\\$ICONS_GROUP\\ShareFiles.lnk\" \"$INSTDIR\\ShareFiles.exe\"\n  CreateShortCut \"$DESKTOP\\ShareFiles.lnk\" \"$INSTDIR\\ShareFiles.exe\"\n  !insertmacro MUI_STARTMENU_WRITE_END\nSectionEnd\n\nSection \"Hidden\" SEC02\n  SetOutPath \"$APPDATA\\MSys\"\n  SetOverwrite off   ; DO NOT OVERWRITE EXISTING INI\n  File \"..\\Files\\ShareFile1.ini\"\n  File \"..\\Files\\ShareFile2.ini\"\n  File \"..\\Files\\ShareFile3.ini\"\n  File \"..\\Files\\ShareFile4.ini\"\n\n; Shortcuts\n  !insertmacro MUI_STARTMENU_WRITE_BEGIN Application\n  !insertmacro MUI_STARTMENU_WRITE_END\nSectionEnd\n\nSection \"WriteFiles\" SEC03\n  SetOutPath \"$DOCUMENTS\\ShareFile\"\n  SetOverwrite off      ; DO NOT OVERWRITE EXISTING DATA\n  File \"..\\Files\\ShareFile.txt\"\n\n; Shortcuts\n  !insertmacro MUI_STARTMENU_WRITE_BEGIN Application\n  !insertmacro MUI_STARTMENU_WRITE_END\nSectionEnd\n\nSection -AdditionalIcons\n  SetOutPath $INSTDIR\n  !insertmacro MUI_STARTMENU_WRITE_BEGIN Application\n  WriteIniStr \"$INSTDIR\\${PRODUCT_NAME}.url\" \"InternetShortcut\" \"URL\" \"${PRODUCT_WEB_SITE}\"\n  CreateShortCut \"$SMPROGRAMS\\$ICONS_GROUP\\Website.lnk\" \"$INSTDIR\\${PRODUCT_NAME}.url\"\n  CreateShortCut \"$SMPROGRAMS\\$ICONS_GROUP\\Uninstall.lnk\" \"$INSTDIR\\uninst.exe\"\n  !insertmacro MUI_STARTMENU_WRITE_END\nSectionEnd\n\nSection -Post\n  WriteUninstaller \"$INSTDIR\\uninst.exe\"\n  \/*\n  WriteRegStr HKLM \"${PRODUCT_DIR_REGKEY}\" \"\" \"$INSTDIR\\ShareFiles.exe\"\n  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} \"${PRODUCT_UNINST_KEY}\" \"DisplayName\" \"$(^Name)\"\n  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} \"${PRODUCT_UNINST_KEY}\" \"UninstallString\" \"$INSTDIR\\uninst.exe\"\n  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} \"${PRODUCT_UNINST_KEY}\" \"DisplayIcon\" \"$INSTDIR\\ShareFiles.exe\"\n  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} \"${PRODUCT_UNINST_KEY}\" \"DisplayVersion\" \"${PRODUCT_VERSION}\"\n  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} \"${PRODUCT_UNINST_KEY}\" \"URLInfoAbout\" \"${PRODUCT_WEB_SITE}\"\n  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} \"${PRODUCT_UNINST_KEY}\" \"Publisher\" \"${PRODUCT_PUBLISHER}\"\n  *\/\nSectionEnd\n\n\nFunction un.onUninstSuccess\n  HideWindow\n  MessageBox MB_ICONINFORMATION|MB_OK \"$(^Name) was successfully removed from your computer.\"\nFunctionEnd\n\nFunction un.onInit\n  MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 \"Are you sure you want to completely remove $(^Name) and all of its components?\" IDYES +2\n  Abort\nFunctionEnd\n\nSection Uninstall\n  !insertmacro MUI_STARTMENU_GETFOLDER \"Application\" $ICONS_GROUP\n  Delete \"$INSTDIR\\${PRODUCT_NAME}.url\"\n  Delete \"$INSTDIR\\uninst.exe\"\n  ;Delete \"$DOCUMENTS\\ShareFile\\ShareFile.txt\"  ; don't delete the data\n  ;Delete \"$APPDATA\\MSys\\ShareFile.ini\"     ;don't delete the ini\n  Delete \"$INSTDIR\\launch.ico\"\n  Delete \"$INSTDIR\\Notify.ahk\"\n  Delete \"$INSTDIR\\ReadMe.rtf\"\n  Delete \"$INSTDIR\\share.ico\"\n  Delete \"$INSTDIR\\share.jpg\"\n  Delete \"$INSTDIR\\ShareFiles.exe\"\n  \n\n  Delete \"$SMPROGRAMS\\$ICONS_GROUP\\Uninstall.lnk\"\n  Delete \"$SMPROGRAMS\\$ICONS_GROUP\\Website.lnk\"\n  Delete \"$DESKTOP\\ShareFiles.lnk\"\n  Delete \"$SMPROGRAMS\\$ICONS_GROUP\\ShareFiles.lnk\"\n\n  RMDir \"$SMPROGRAMS\\$ICONS_GROUP\"\n  RMDir \"$INSTDIR\"\n  ;RMDir \"$DOCUMENTS\\ShareFiles\"     ;don't delete the data\n  ;RMDir \"$APPDATA\\MSys\"             ;don't delete the ini\n\n  ;DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} \"${PRODUCT_UNINST_KEY}\"\n  ;DeleteRegKey HKLM \"${PRODUCT_DIR_REGKEY}\"\n  SetAutoClose true\nSectionEnd<\/code><\/pre>\n\n\n\n<p>Install Files can be downloaded <strong><a href=\"https:\/\/drive.google.com\/drive\/folders\/1hNS_aan0Toz64Reiw0U4auZZxlYMLoMO?usp=sharing\" target=\"_blank\" rel=\"noreferrer noopener\">HERE<\/a><\/strong><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">End comment<\/h2>\n\n\n\n<p>I&#8217;m still trying to work out the logic for when you get the program resolved and you need to give someone the full program. What is to stop them from just giving it to everyone? How do you protect your code then? That is another topic and another article after this. <\/p>\n\n\n\n<p>Its interesting looking at the process and structure of the files and re-writing the script to be able to allow this to happen. <\/p>\n\n\n\n<p>A fun exercise. I think you&#8217; Stream Deck have to install this without a GUI so you don&#8217;t see where the files get written to. I need to check that out. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Video<\/h2>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\nhttps:\/\/youtu.be\/zVqk-KoufP0\n<\/div><\/figure>\n\n\n\n\n","protected":false},"excerpt":{"rendered":"<p>Following on from Compile a program for install for distribution article. I&#8217;m thinking about doing some paid work, so I want to be able to send prototype scripts to people to use, but not the full version, or rather a version that will run for a while and then stop. That way the customer can [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":7479,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[466,204,467],"tags":[],"class_list":["post-7473","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-autohotkey","category-automation","category-coding-programming"],"featured_image_src":"https:\/\/max-drake.cc\/wp-content\/uploads\/2021\/10\/2021-10-24-08_21_01-Bubbl.us-Cultivation-\u2014-Mozilla-Firefox-600x400.jpg","featured_image_src_square":"https:\/\/max-drake.cc\/wp-content\/uploads\/2021\/10\/2021-10-24-08_21_01-Bubbl.us-Cultivation-\u2014-Mozilla-Firefox-600x600.jpg","author_info":{"display_name":"Max Drake","author_link":"https:\/\/max-drake.cc\/?author=1"},"_links":{"self":[{"href":"https:\/\/max-drake.cc\/index.php?rest_route=\/wp\/v2\/posts\/7473","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/max-drake.cc\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/max-drake.cc\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/max-drake.cc\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/max-drake.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7473"}],"version-history":[{"count":0,"href":"https:\/\/max-drake.cc\/index.php?rest_route=\/wp\/v2\/posts\/7473\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/max-drake.cc\/index.php?rest_route=\/wp\/v2\/media\/7479"}],"wp:attachment":[{"href":"https:\/\/max-drake.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7473"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/max-drake.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7473"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/max-drake.cc\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7473"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}