Ejemplo n.º 1
0
        private static int Main(string[] args)
        {
            if (args.Length != 0)
            {
                return((int)ReturnValue.InvalidArgumentCode);
            }

            HelperTools.SetupEncoding();

            try
            {
                foreach (var result in ScriptManager.GetScripts())
                {
                    var converted = result.Select(x => new KeyValuePair <string, object>(x.Key, x.Value)).ToList();
                    Console.WriteLine(HelperTools.KeyValueListToConsoleOutput(converted));
                }

                return((int)ReturnValue.OkCode);
            }
            catch (IOException ex)
            {
                LogWriter.WriteExceptionToLog(ex);
                return(HelperTools.HandleHrefMessage(ex));
            }
            catch (Exception ex)
            {
                LogWriter.WriteExceptionToLog(ex);
                return((int)ReturnValue.FunctionFailedCode);
            }
        }
Ejemplo n.º 2
0
        public static void WriteUpdateList()
        {
            var wuaSession  = new UpdateSessionClass();
            var wuaSearcher = wuaSession.CreateUpdateSearcher();
            var wuaSearch   = wuaSearcher.Search("IsInstalled=1 and IsPresent=1 and Type='Software'");
            var updates     = wuaSearch.Updates.OfType <IUpdate>().ToList();

            foreach (var update in updates)
            {
                var id = update.Identity;

                var result = HelperTools.KeyValueListToConsoleOutput(new List <KeyValuePair <string, object> >
                {
                    new KeyValuePair <string, object>(nameof(id.UpdateID), id.UpdateID),
                    new KeyValuePair <string, object>(nameof(id.RevisionNumber), id.RevisionNumber),

                    new KeyValuePair <string, object>(nameof(update.Title), update.Title),
                    new KeyValuePair <string, object>(nameof(update.IsUninstallable), update.IsUninstallable),

                    new KeyValuePair <string, object>(nameof(update.SupportUrl), update.SupportUrl),

                    new KeyValuePair <string, object>(nameof(update.MinDownloadSize), update.MinDownloadSize),
                    new KeyValuePair <string, object>(nameof(update.MaxDownloadSize), update.MaxDownloadSize),
                    new KeyValuePair <string, object>(nameof(update.LastDeploymentChangeTime), update.LastDeploymentChangeTime)
                });

                Console.WriteLine(result);
            }
        }
Ejemplo n.º 3
0
        private static int Main(string[] args)
        {
            HelperTools.SetupEncoding();

            try
            {
                ProcessCommandlineArguments(args);

                switch (_queryType)
                {
                case QueryType.Uninstall:
                    Console.WriteLine("Uninstalling " + _appId);
                    var tweakEntry = Tweaks.GetEntry(_appId);
                    if (tweakEntry == null)
                    {
                        throw new ArgumentException("Could not find a tweak with this name to uninstall");
                    }
                    tweakEntry.OnUninstall(true);
                    break;

                case QueryType.List:
                    foreach (var result in Tweaks.GetConsoleOutput())
                    {
                        var converted = result.Select(x => new KeyValuePair <string, object>(x.Key, x.Value)).ToList();
                        Console.WriteLine(HelperTools.KeyValueListToConsoleOutput(converted));
                    }
                    break;

                default:
                    Console.WriteLine("Accepted commands:\nlist\nuninstall <id>");
                    break;
                }
            }
            catch (OperationCanceledException)
            {
                return((int)ReturnValue.CancelledByUserCode);
            }
            catch (FormatException ex)
            {
                LogWriter.WriteExceptionToLog(ex);
                return((int)ReturnValue.InvalidArgumentCode);
            }
            catch (Exception ex)
            {
                LogWriter.WriteExceptionToLog(ex);
                return((int)ReturnValue.UnexpectedNetworkErrorCode);
            }
            return((int)ReturnValue.OkCode);
        }