예제 #1
0
        private async Task JavaFolderCheck(string bits, string pf)
        {
            var    path = string.Format(@"\\{0}\c$\{1}\", IPAddress, pf);
            string command;
            var    javaPath = Path.Combine(path, "Java");

            if (Directory.Exists(javaPath))
            {
                var folders = Directory.GetDirectories(javaPath);
                foreach (string folder in folders)
                {
                    var fullpathfile = Path.Combine(folder, @"bin\java.exe");
                    if (File.Exists(fullpathfile))
                    {
                        DirectoryInfo folder1       = new DirectoryInfo(folder);
                        var           fulllocalpath = string.Format(@"c:\{1}\Java\{0}", folder1.Name, pf);
                        command = string.Format(@"""{0}\bin\Java.exe"" -version", fulllocalpath);
                        var result = await JavaVersion(command);

                        if (!result.Contains("ERROR"))
                        {
                            Javas.Add(new RemoteProgramData {
                                Version = result, Name = "Java", FullPath = fulllocalpath, InstallFolder = path, Bit = bits
                            });
                        }
                    }
                }
            }
        }
예제 #2
0
        static SettingProxy()
        {
            try
            {
                Minecrafts = Searcher.SearchMC();
                Mods       = Searcher.SearchItem <ModData>(Environment.CurrentDirectory + "\\.minecraft\\");
                ResPack    = Searcher.SearchItem <ResPackData>(Environment.CurrentDirectory + "\\.minecraft\\");
                Screenshot = Searcher.SearchItem <ScreenshotData>(Environment.CurrentDirectory + "\\.minecraft\\");
                ShaderPack = Searcher.SearchItem <ShaderPackData>(Environment.CurrentDirectory + "\\.minecraft\\");
                Saves      = Searcher.SearchItem <SaveData>(Environment.CurrentDirectory + "\\.minecraft\\");
                if (SettingProxy.Name?.Length > 0)
                {
                    User.Name = SettingProxy.Name;
                }
                else
                {
                    User.Name = "NAME";
                }

                Javas = Searcher.GetJavas();
                foreach (var item in JavasPath)
                {
                    if (!Javas.ContainsValue(item))
                    {
                        Javas.Add(item, item);
                    }
                }
                foreach (var item in Javas.Values)
                {
                    if (!JavasPath.Contains(item))
                    {
                        JavasPath.Add(item);
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.WriteError(ex);
                throw ex;
            }
        }
예제 #3
0
        public async Task <bool> SetJNLPAssoication(RemoteProgramData toset)
        {
            if (toset == null)
            {
                return(false);
            }
            if (Javas.Any(j => j.FullVersion.ToLower().Contains("not installed")) || Javas.Count == 0 || Javas == null)
            {
                return(false);
            }
            Log(log.Info, string.Format("Setting .jnlp file association to {0}", toset.FullVersion));
            Processing++;
            try
            {
                var f = new NTAccount(CurrentUser);
                var s = (SecurityIdentifier)f.Translate(typeof(SecurityIdentifier));

                var fixreg = new Tool.PAExec(IPAddress, string.Format(@"-s REG DELETE ""HKU\{0}\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.jnlp\UserChoice"" /v Progid /f", s.ToString()));
                await fixreg.Run();

                var assoc = new Tool.PAExec(IPAddress, @"cmd /c assoc .jnlp=jnlpfile");
                await assoc.Run();

                var paexec = new Tool.PAExec(IPAddress, string.Format(@"cmd /c ftype jnlpfile=""{0}\bin\javaws.exe"" ""%1""", toset.FullPath));
                await paexec.Run();

                Log(log.Info, "Process complete");

                Processing--;
                return(true);
            }
            catch (Exception ex)
            {
                Log(log.Error, ex.ToString());
                Processing--;
                return(false);
            }
        }