Пример #1
0
 private static void Main()
 {
     Log.AllowLogging();
     MessageBoxEx.TopMost = true;
     if (Process.GetProcessesByName(Resources.AppName).Length > 0)
     {
         MessageBoxEx.Show(Resources.Msg_Warn_00, Resources.WindowTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning);
         Environment.Exit(1);
     }
     using (new Mutex(true, ProcessEx.CurrentName, out bool newInstance))
     {
         if (!newInstance)
         {
             return;
         }
         if (!Elevation.WritableLocation())
         {
             Elevation.RestartAsAdministrator();
         }
         Ini.SetFile(Path.ChangeExtension(PathEx.LocalPath, ".ini"));
         if ((DateTime.Now - Ini.Read("History", "LastCheck", DateTime.MinValue)).Days < 7)
         {
             return;
         }
         Application.EnableVisualStyles();
         Application.SetCompatibleTextRenderingDefault(false);
         Application.Run(new MainForm());
     }
 }
Пример #2
0
 private static void Main()
 {
     Log.AllowLogging();
     using (new Mutex(true, ProcessEx.CurrentName, out bool newInstance))
     {
         if (!newInstance)
         {
             return;
         }
         if (!Elevation.WritableLocation())
         {
             Elevation.RestartAsAdministrator();
         }
         Application.EnableVisualStyles();
         Application.SetCompatibleTextRenderingDefault(false);
         try
         {
             Application.Run(new MainForm());
         }
         catch (Exception ex)
         {
             Log.Write(ex);
         }
     }
 }
Пример #3
0
        internal static bool AppsSuiteIsHealthy(bool repair = true)
        {
            if (!Elevation.WritableLocation())
            {
                Elevation.RestartAsAdministrator();
            }
            while (true)
            {
                try
                {
                    if (!File.Exists(CorePaths.AppsLauncher) ||
                        !File.Exists(CorePaths.AppsSuiteUpdater) ||
                        !File.Exists(CorePaths.FileArchiver))
                    {
                        throw new FileNotFoundException();
                    }
                }
                catch (FileNotFoundException ex)
                {
                    Log.Write(ex);
                    if (!repair)
                    {
                        return(false);
                    }
                    Repair(ActionGuid.RepairAppsSuite, true);
                }

                try
                {
                    foreach (var dir in CorePaths.AppDirs)
                    {
                        if (!Directory.Exists(dir))
                        {
                            throw new PathNotFoundException(dir);
                        }
                    }
                }
                catch (PathNotFoundException ex)
                {
                    Log.Write(ex);
                    if (!repair)
                    {
                        return(false);
                    }
                    Repair(ActionGuid.RepairDirs, false);
                }

                if (!repair)
                {
                    return(true);
                }
                repair = false;
            }
        }
Пример #4
0
        private static bool RequirementsAvailable()
        {
            if (!Elevation.WritableLocation())
            {
                Elevation.RestartAsAdministrator();
            }
            string[] sArray =
            {
                "Apps\\.free\\",
                "Apps\\.repack\\",
                "Apps\\.share\\",
                "Assets\\images.dat",
#if x86
                "Binaries\\AppsDownloader.exe",
#else
                "Binaries\\AppsDownloader64.exe",
#endif
                "Binaries\\Updater.exe"
            };
            foreach (var s in sArray)
            {
                var path = PathEx.Combine(PathEx.LocalDir, s);
                if (s.EndsWith("\\"))
                {
                    try
                    {
                        if (!Directory.Exists(path))
                        {
                            RepairAppsSuiteHandler();
                        }
                        if (!Directory.Exists(path))
                        {
                            throw new PathNotFoundException(path);
                        }
                    }
                    catch (Exception ex)
                    {
                        Log.Write(ex);
                        return(false);
                    }
                }
                else
                {
                    if (!File.Exists(path))
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
Пример #5
0
 private static bool RequirementsAvailable()
 {
     if (!Elevation.WritableLocation())
     {
         Elevation.RestartAsAdministrator();
     }
     string[] rArray =
     {
         "..\\Assets\\images.dat",
         "Helper\\7z\\7z.dll",
         "Helper\\7z\\7zG.exe",
         "Helper\\7z\\x64\\7z.dll",
         "Helper\\7z\\x64\\7zG.exe"
     };
     return(rArray.Select(s => PathEx.Combine(PathEx.LocalDir, s)).All(File.Exists));
 }
Пример #6
0
        internal static bool AppsSuiteIsHealthy(bool repair = true)
        {
            if (!Elevation.WritableLocation())
            {
                Elevation.RestartAsAdministrator();
            }

            VersionValidation();

            while (true)
            {
                try
                {
                    if (!File.Exists(CorePaths.AppsDownloader) ||
                        !File.Exists(CorePaths.AppsSuiteUpdater) ||
                        !File.Exists(CorePaths.FileArchiver))
                    {
                        throw new FileNotFoundException();
                    }
                }
                catch (FileNotFoundException ex)
                {
                    Log.Write(ex);
                    if (!repair)
                    {
                        return(false);
                    }
                    RepairAppsSuite();
                }

                try
                {
                    foreach (var dir in CorePaths.AppDirs.Where(dir => !Directory.Exists(dir)))
                    {
                        throw new PathNotFoundException(dir);
                    }
                }
                catch (PathNotFoundException ex)
                {
                    Log.Write(ex);
                    if (!repair)
                    {
                        return(false);
                    }
                    RepairAppsSuiteDirs();
                }

                try
                {
                    var envDir = EnvironmentEx.GetVariableValue(Settings.EnvironmentVariable);
                    if (!Settings.DeveloperVersion && !string.IsNullOrWhiteSpace(envDir) && !envDir.EqualsEx(PathEx.LocalDir))
                    {
                        throw new ArgumentInvalidException(nameof(envDir));
                    }
                }
                catch (ArgumentInvalidException ex)
                {
                    Log.Write(ex);
                    if (!repair)
                    {
                        return(false);
                    }
                    RepairEnvironmentVariable();
                }

                if (!repair)
                {
                    return(true);
                }
                repair = false;
            }
        }
Пример #7
0
        internal static void RepairAppsSuiteDirs()
        {
            if (!Elevation.WritableLocation())
            {
                Elevation.RestartAsAdministrator(ActionGuid.RepairDirs);
            }

            foreach (var dirs in new[]
            {
                CorePaths.AppDirs,
                CorePaths.UserDirs
            })
            {
                foreach (var dir in dirs)
                {
                    if (!DirectoryEx.Create(dir))
                    {
                        Elevation.RestartAsAdministrator(ActionGuid.RepairDirs);
                    }
                }
            }

            var iniMap = new[]
            {
                new[]
                {
                    CorePaths.AppDirs.First(),
                    "IconResource=..\\Assets\\FolderIcons.dll,3"
                },
                new[]
                {
                    CorePaths.AppDirs.Second(),
                    "LocalizedResourceName=\"Port-Able\" - Freeware",
                    "IconResource=..\\..\\Assets\\FolderIcons.dll,4"
                },
                new[]
                {
                    CorePaths.AppDirs.Third(),
                    "LocalizedResourceName=\"PortableApps\" - Repacks",
                    "IconResource=..\\..\\Assets\\FolderIcons.dll,2"
                },
                new[]
                {
                    CorePaths.AppDirs.Last(),
                    "LocalizedResourceName=\"Custom\" - Shareware",
                    "IconResource=..\\..\\Assets\\FolderIcons.dll,1"
                },
                new[]
                {
                    PathEx.Combine(PathEx.LocalDir, "Assets"),
                    "IconResource=FolderIcons.dll,5"
                },
                new[]
                {
                    PathEx.Combine(PathEx.LocalDir, "Binaries"),
                    "IconResource=..\\Assets\\FolderIcons.dll,5"
                },
                new[]
                {
                    CorePaths.UserDirs.First(),
                    "LocalizedResourceName=Profile",
                    "IconResource=%SystemRoot%\\system32\\imageres.dll,117",
                    "IconFile=%SystemRoot%\\system32\\shell32.dll",
                    "IconIndex=-235"
                },
                new[]
                {
                    PathEx.Combine(PathEx.LocalDir, "Documents", ".cache"),
                    "IconResource=%SystemRoot%\\system32\\imageres.dll,112"
                },
                new[]
                {
                    CorePaths.UserDirs.Second(),
                    "LocalizedResourceName=@%SystemRoot%\\system32\\shell32.dll,-21770",
                    "IconResource=%SystemRoot%\\system32\\imageres.dll,-112",
                    "IconFile=%SystemRoot%\\system32\\shell32.dll",
                    "IconIndex=-235"
                },
                new[]
                {
                    CorePaths.UserDirs.Third(),
                    "LocalizedResourceName=@%SystemRoot%\\system32\\shell32.dll,-21790",
                    "IconResource=%SystemRoot%\\system32\\imageres.dll,-108",
                    "IconFile=%SystemRoot%\\system32\\shell32.dll",
                    "IconIndex=-237",
                    "InfoTip=@%SystemRoot%\\system32\\shell32.dll,-12689"
                },
                new[]
                {
                    CorePaths.UserDirs.Fourth(),
                    "LocalizedResourceName=@%SystemRoot%\\system32\\shell32.dll,-21779",
                    "IconResource=%SystemRoot%\\system32\\imageres.dll,-113",
                    "IconFile=%SystemRoot%\\system32\\shell32.dll",
                    "IconIndex=-236",
                    "InfoTip=@%SystemRoot%\\system32\\shell32.dll,-12688"
                },
                new[]
                {
                    CorePaths.UserDirs.Last(),
                    "LocalizedResourceName=@%SystemRoot%\\system32\\shell32.dll,-21791",
                    "IconResource=%SystemRoot%\\system32\\imageres.dll,-189",
                    "IconFile=%SystemRoot%\\system32\\shell32.dll",
                    "IconIndex=-238",
                    "InfoTip=@%SystemRoot%\\system32\\shell32.dll,-12690"
                },
                new[]
                {
                    PathEx.Combine(PathEx.LocalDir, "Help"),
                    "IconResource=..\\Assets\\FolderIcons.dll,4"
                }
            };

            for (var i = 0; i < iniMap.Length; i++)
            {
                var array = iniMap[i];
                var dir   = array.FirstOrDefault();
                if (!PathEx.IsValidPath(dir) || i >= iniMap.Length - 2 && !Directory.Exists(dir))
                {
                    continue;
                }
                if (!Elevation.WritableLocation(dir))
                {
                    Elevation.RestartAsAdministrator(ActionGuid.RepairDirs);
                }
                var path = PathEx.Combine(dir, "desktop.ini");
                foreach (var str in array.Skip(1))
                {
                    var ent = str?.Split('=');
                    if (ent?.Length != 2)
                    {
                        continue;
                    }
                    var key = ent.FirstOrDefault();
                    if (string.IsNullOrEmpty(key))
                    {
                        continue;
                    }
                    var val = ent.LastOrDefault();
                    if (string.IsNullOrEmpty(val))
                    {
                        continue;
                    }
                    Ini.WriteDirect(".ShellClassInfo", key, val, path);
                }
                FileEx.SetAttributes(path, FileAttributes.System | FileAttributes.Hidden);
                DirectoryEx.SetAttributes(dir, FileAttributes.ReadOnly);
            }
        }
Пример #8
0
        private static bool RequirementsAvailable()
        {
            if (!Elevation.WritableLocation())
            {
                Elevation.RestartAsAdministrator();
            }
            const string repairAppsSuite  = "{48FDE635-60E6-41B5-8F9D-674E9F535AC7}";
            const string disableInterface = "{9AB50CEB-3D99-404E-BD31-4E635C09AF0F}";

            string[] sArray =
            {
                "..\\Apps\\.free\\",
                "..\\Apps\\.repack\\",
                "..\\Apps\\.share\\",
                "..\\Assets\\images.dat",
                "Updater.exe",
#if x86
                "Helper\\7z\\7z.dll",
                "Helper\\7z\\7zG.exe",
                "..\\AppsLauncher.exe",
#else
                "Helper\\7z\\x64\\7z.dll",
                "Helper\\7z\\x64\\7zG.exe",
                "..\\AppsLauncher64.exe"
#endif
            };
            foreach (var s in sArray)
            {
                var path = PathEx.Combine(PathEx.LocalDir, s);
                if (s.EndsWith("\\"))
                {
                    try
                    {
                        if (!Directory.Exists(path))
                        {
                            var psi = new ProcessStartInfo
                            {
                                Arguments = $"{repairAppsSuite} {disableInterface}",
#if x86
                                FileName = "%CurDir%\\..\\AppsLauncher.exe"
#else
                                FileName = "%CurDir%\\..\\AppsLauncher64.exe"
#endif
                            };
                            ProcessEx.Start(psi)?.WaitForExit();
                        }
                        if (!Directory.Exists(path))
                        {
                            throw new PathNotFoundException(path);
                        }
                    }
                    catch (Exception ex)
                    {
                        Log.Write(ex);
                        return(false);
                    }
                }
                else
                {
                    if (!File.Exists(path))
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }