Setup Factory is a very easy-to-use packaging software, and its operating registry is also very simple.
1. Create a "key" in the registry ( Registry.CreateKey )
Registry.CreateKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\JMElectVersion");
2. Determine whether the specified registry key exists and return true or false ( Registry.DoesKeyExist )
local IsJMElectVersion = Registry.DoesKeyExist(HKEY_LOCAL_MACHINE, "SOFTWARE\\JMElectVersion");
3. Returns the data of the specified registry value ( Registry.GetValue )
local JEtInstallPath = Registry.GetValue(HKEY_LOCAL_MACHINE, "SOFTWARE\\JMElectVersion", "JMElectInstallPath",true);
if(JEtInstallPath ~= "")then -- determine whether the key value exists
--indicates that the key value exists
end
4. Returns a string containing the contents of the given session variable ( SessionVar.Expand )
local JMElectProductName = SessionVar.Expand ("%ProductName%");
5. Add (or concatenate) two strings and return the result as a new string ( String.Concat )
String.Concat("Detected that the software has been installed","If you reinstall the installation directory, you cannot change the installation directory. If you want to change the directory, please uninstall and then install. Are you sure you want to reinstall?");
6. Display a dialog with message information ( Dialog.Message )
Qid = Dialog.Message(JMElectProductName, String.Concat("Detected that the software has been installed",", if you reinstall, you cannot change the installation directory. If you want to change the directory, please uninstall and then install. Are you sure you want to reinstall? "), MB_OKCANCEL, MB_ICONQUESTION, MB_DEFBUTTON1);
if(Qid == IDCANCEL) then -- Qid is a global variable, other forms can be used, and the variable name cannot be included in the internally defined name, see the description later.
Application.Exit();
else
//do the operation
local resultAppFolder = Registry.GetValue(HKEY_LOCAL_MACHINE, "SOFTWARE\\JMElectVersion", "JMElectInstallPath", true); -- Get the original installation directory. If this item is not set, it can be decomposed from the uninstall key.
SessionVar.Set("%AppFolder%", resultAppFolder); -- set the installation directory to the original installation directory
end
end
7. Run the executable ( File.Run )
result = File.Run(SessionVar.Expand("%TempLaunchFolder%\\dotNetFx40_Full_x86_x64.exe"), "", "", SW_SHOWNORMAL, true);
%TempLaunchFolder% is the original file path
8. Delete the specified folder and all files in the folder ( Folder.DeleteTree )
Folder.DeleteTree(SessionVar.Expand ("%AppFolder%"), nil); -- delete all files in the installation directory (can be operated when uninstalling)